Key and Path Formats
PascalCase keys with key_format :pascal and kebab-case paths with path_format :kebab
API Definition
config/apis/nimble_gecko.rb
rb
# frozen_string_literal: true
Apiwork::API.define '/nimble_gecko' do
key_format :pascal
path_format :kebab
export :openapi
export :apiwork
resources :meal_plans
endModels
app/models/nimble_gecko/meal_plan.rb
rb
# frozen_string_literal: true
module NimbleGecko
class MealPlan < ApplicationRecord
has_many :cooking_steps, dependent: :destroy
accepts_nested_attributes_for :cooking_steps, allow_destroy: true
validates :title, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| cook_time | integer | ✓ | |
| created_at | datetime | ||
| serving_size | integer | ✓ | |
| title | string | ||
| updated_at | datetime |
app/models/nimble_gecko/cooking_step.rb
rb
# frozen_string_literal: true
module NimbleGecko
class CookingStep < ApplicationRecord
belongs_to :meal_plan
validates :instruction, presence: true
validates :step_number, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| created_at | datetime | ||
| duration_minutes | integer | ✓ | |
| instruction | string | ||
| meal_plan_id | string | ||
| step_number | integer | ||
| updated_at | datetime |
Representations
app/representations/nimble_gecko/meal_plan_representation.rb
rb
# frozen_string_literal: true
module NimbleGecko
class MealPlanRepresentation < Apiwork::Representation::Base
attribute :id
attribute :title, writable: true
attribute :cook_time, writable: true
attribute :serving_size, writable: true
attribute :created_at
attribute :updated_at
has_many :cooking_steps, include: :always, writable: true
end
endapp/representations/nimble_gecko/cooking_step_representation.rb
rb
# frozen_string_literal: true
module NimbleGecko
class CookingStepRepresentation < Apiwork::Representation::Base
attribute :id
attribute :step_number, writable: true
attribute :instruction, writable: true
attribute :duration_minutes, writable: true
end
endContracts
app/contracts/nimble_gecko/meal_plan_contract.rb
rb
# frozen_string_literal: true
module NimbleGecko
class MealPlanContract < Apiwork::Contract::Base
representation MealPlanRepresentation
end
endControllers
app/controllers/nimble_gecko/meal_plans_controller.rb
rb
# frozen_string_literal: true
module NimbleGecko
class MealPlansController < ApplicationController
before_action :set_meal_plan, only: %i[show update destroy]
def index
meal_plans = MealPlan.all
expose meal_plans
end
def show
expose meal_plan
end
def create
meal_plan = MealPlan.create(contract.body[:meal_plan])
expose meal_plan
end
def update
meal_plan.update(contract.body[:meal_plan])
expose meal_plan
end
def destroy
meal_plan.destroy
expose meal_plan
end
private
attr_reader :meal_plan
def set_meal_plan
@meal_plan = MealPlan.find(params[:id])
end
end
endRequest Examples
Create meal plan with PascalCase body
Request
http
POST /nimble-gecko/meal-plans
Content-Type: application/json
{
"MealPlan": {
"Title": "Pasta Carbonara",
"CookTime": 30,
"ServingSize": 4,
"CookingSteps": [
{
"OP": "create",
"StepNumber": 1,
"Instruction": "Boil salted water",
"DurationMinutes": 10
},
{
"OP": "create",
"StepNumber": 2,
"Instruction": "Cook pasta until al dente",
"DurationMinutes": 8
},
{
"OP": "create",
"StepNumber": 3,
"Instruction": "Mix with egg yolk sauce",
"DurationMinutes": 5
}
]
}
}Response 201
json
{
"MealPlan": {
"Id": "60e6912b-2e98-5f0c-892b-391c9c742417",
"Title": "Pasta Carbonara",
"CookTime": 30,
"ServingSize": 4,
"CreatedAt": "2026-04-01T12:00:00.000Z",
"UpdatedAt": "2026-04-01T12:00:00.000Z",
"CookingSteps": [
{
"Id": "38b78662-d87b-5207-8f3c-06ec107d743f",
"StepNumber": 1,
"Instruction": "Boil salted water",
"DurationMinutes": 10
},
{
"Id": "24a40914-0737-5381-9cf9-229afde32839",
"StepNumber": 2,
"Instruction": "Cook pasta until al dente",
"DurationMinutes": 8
},
{
"Id": "ce3678af-6e42-5784-b675-8205a51d57ce",
"StepNumber": 3,
"Instruction": "Mix with egg yolk sauce",
"DurationMinutes": 5
}
]
}
}List meal plans
Request
http
GET /nimble-gecko/meal-plansResponse 200
json
{
"MealPlans": [
{
"Id": "60e6912b-2e98-5f0c-892b-391c9c742417",
"Title": "Pasta Carbonara",
"CookTime": 30,
"ServingSize": 4,
"CreatedAt": "2026-04-01T12:00:00.000Z",
"UpdatedAt": "2026-04-01T12:00:00.000Z",
"CookingSteps": []
},
{
"Id": "3b027918-ddeb-5a41-95d9-cc041dce69e9",
"Title": "Caesar Salad",
"CookTime": 15,
"ServingSize": 2,
"CreatedAt": "2026-04-01T12:00:00.000Z",
"UpdatedAt": "2026-04-01T12:00:00.000Z",
"CookingSteps": []
}
],
"Pagination": {
"Items": 2,
"Total": 1,
"Current": 1,
"Next": null,
"Prev": null
}
}Update meal plan with PascalCase body
Request
http
PATCH /nimble-gecko/meal-plans/60e6912b-2e98-5f0c-892b-391c9c742417
Content-Type: application/json
{
"MealPlan": {
"CookTime": 25,
"ServingSize": 6
}
}Response 200
json
{
"MealPlan": {
"Id": "60e6912b-2e98-5f0c-892b-391c9c742417",
"Title": "Pasta Carbonara",
"CookTime": 25,
"ServingSize": 6,
"CreatedAt": "2026-04-01T12:00:00.000Z",
"UpdatedAt": "2026-04-01T12:00:00.000Z",
"CookingSteps": []
}
}Exports
OpenAPI
yml
---
openapi: 3.1.0
info:
title: "/nimble_gecko"
version: 1.0.0
paths:
"/meal-plans":
get:
operationId: MealPlansIndex
parameters:
- in: query
name: Page
required: false
schema:
"$ref": "#/components/schemas/MealPlanPage"
responses:
'200':
content:
application/json:
schema:
properties:
MealPlans:
items:
"$ref": "#/components/schemas/MealPlan"
type: array
Meta:
properties: {}
type: object
Pagination:
"$ref": "#/components/schemas/OffsetPagination"
type: object
required:
- MealPlans
- Pagination
description: ''
post:
operationId: MealPlansCreate
requestBody:
content:
application/json:
schema:
properties:
MealPlan:
"$ref": "#/components/schemas/MealPlanCreatePayload"
type: object
required:
- MealPlan
required: true
responses:
'200':
content:
application/json:
schema:
properties:
MealPlan:
"$ref": "#/components/schemas/MealPlan"
Meta:
properties: {}
type: object
type: object
required:
- MealPlan
description: ''
'422':
description: Unprocessable Entity
content:
application/json:
schema:
properties:
issues:
items:
"$ref": "#/components/schemas/Error"
type: array
required:
- issues
type: object
"/meal-plans/{Id}":
get:
operationId: MealPlansShow
parameters:
- in: path
name: Id
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
properties:
MealPlan:
"$ref": "#/components/schemas/MealPlan"
Meta:
properties: {}
type: object
type: object
required:
- MealPlan
description: ''
patch:
operationId: MealPlansUpdate
parameters:
- in: path
name: Id
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
MealPlan:
"$ref": "#/components/schemas/MealPlanUpdatePayload"
type: object
required:
- MealPlan
required: true
responses:
'200':
content:
application/json:
schema:
properties:
MealPlan:
"$ref": "#/components/schemas/MealPlan"
Meta:
properties: {}
type: object
type: object
required:
- MealPlan
description: ''
'422':
description: Unprocessable Entity
content:
application/json:
schema:
properties:
issues:
items:
"$ref": "#/components/schemas/Error"
type: array
required:
- issues
type: object
delete:
operationId: MealPlansDestroy
parameters:
- in: path
name: Id
required: true
schema:
type: string
responses:
'204':
description: ''
components:
schemas:
CookingStep:
properties:
DurationMinutes:
type:
- integer
- 'null'
Id:
type: string
Instruction:
type: string
StepNumber:
type: integer
type: object
required:
- DurationMinutes
- Id
- Instruction
- StepNumber
CookingStepNestedCreatePayload:
properties:
OP:
const: create
type: string
DurationMinutes:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
default:
Instruction:
type: string
StepNumber:
type: integer
minimum: -2147483648
maximum: 2147483647
type: object
required:
- OP
- Instruction
- StepNumber
CookingStepNestedDeletePayload:
properties:
OP:
const: delete
type: string
Id:
type: string
type: object
required:
- OP
- Id
CookingStepNestedPayload:
oneOf:
- "$ref": "#/components/schemas/CookingStepNestedCreatePayload"
- "$ref": "#/components/schemas/CookingStepNestedUpdatePayload"
- "$ref": "#/components/schemas/CookingStepNestedDeletePayload"
discriminator:
mapping:
Create: "#/components/schemas/CookingStepNestedCreatePayload"
Update: "#/components/schemas/CookingStepNestedUpdatePayload"
Delete: "#/components/schemas/CookingStepNestedDeletePayload"
propertyName: OP
CookingStepNestedUpdatePayload:
properties:
OP:
const: update
type: string
DurationMinutes:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
Id:
type: string
Instruction:
type: string
StepNumber:
type: integer
minimum: -2147483648
maximum: 2147483647
type: object
required:
- OP
Error:
properties:
Issues:
items:
"$ref": "#/components/schemas/ErrorIssue"
type: array
Layer:
enum:
- http
- contract
- domain
type: string
type: object
required:
- Issues
- Layer
ErrorIssue:
properties:
Code:
type: string
Detail:
type: string
Meta:
properties: {}
type: object
Path:
items:
oneOf:
- type: string
- type: integer
type: array
Pointer:
type: string
type: object
required:
- Code
- Detail
- Meta
- Path
- Pointer
MealPlan:
properties:
CookTime:
type:
- integer
- 'null'
CookingSteps:
items:
"$ref": "#/components/schemas/CookingStep"
type: array
CreatedAt:
type: string
format: date-time
Id:
type: string
ServingSize:
type:
- integer
- 'null'
Title:
type: string
UpdatedAt:
type: string
format: date-time
type: object
required:
- CookTime
- CookingSteps
- CreatedAt
- Id
- ServingSize
- Title
- UpdatedAt
MealPlanCreatePayload:
properties:
CookTime:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
default:
CookingSteps:
items:
"$ref": "#/components/schemas/CookingStepNestedPayload"
type: array
ServingSize:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
default:
Title:
type: string
type: object
required:
- Title
MealPlanPage:
properties:
Number:
type: integer
minimum: 1
Size:
type: integer
minimum: 1
maximum: 100
type: object
MealPlanUpdatePayload:
properties:
CookTime:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
CookingSteps:
items:
"$ref": "#/components/schemas/CookingStepNestedPayload"
type: array
ServingSize:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
Title:
type: string
type: object
OffsetPagination:
properties:
Current:
type: integer
Items:
type: integer
Next:
type:
- integer
- 'null'
Prev:
type:
- integer
- 'null'
Total:
type: integer
type: object
required:
- Current
- Items
- TotalApiwork
json
{
"base_path": "/nimble-gecko",
"enums": [
{
"deprecated": false,
"description": null,
"example": null,
"name": "error_layer",
"scope": null,
"values": [
"http",
"contract",
"domain"
]
}
],
"error_codes": [
{
"description": "Unprocessable Entity",
"name": "unprocessable_entity",
"status": 422
}
],
"fingerprint": "9547eaf6efc1a39e",
"info": null,
"locales": [],
"resources": [
{
"actions": [
{
"name": "meal_plans.index",
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/meal-plans",
"raises": [],
"request": {
"body": [],
"description": null,
"query": [
{
"name": "Page",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "meal_plan_page"
}
]
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "MealPlans",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "meal_plan"
}
},
{
"name": "Meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": []
},
{
"name": "Pagination",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "offset_pagination"
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "meal_plans.show",
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/meal-plans/:Id",
"raises": [],
"request": {
"body": [],
"description": null,
"query": []
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "MealPlan",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "meal_plan"
},
{
"name": "Meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": []
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "meal_plans.create",
"deprecated": false,
"description": null,
"method": "post",
"operation_id": null,
"path": "/meal-plans",
"raises": [
"unprocessable_entity"
],
"request": {
"body": [
{
"name": "MealPlan",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "meal_plan_create_payload"
}
],
"description": null,
"query": []
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "MealPlan",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "meal_plan"
},
{
"name": "Meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": []
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "meal_plans.update",
"deprecated": false,
"description": null,
"method": "patch",
"operation_id": null,
"path": "/meal-plans/:Id",
"raises": [
"unprocessable_entity"
],
"request": {
"body": [
{
"name": "MealPlan",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "meal_plan_update_payload"
}
],
"description": null,
"query": []
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "MealPlan",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "meal_plan"
},
{
"name": "Meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": []
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "meal_plans.destroy",
"deprecated": false,
"description": null,
"method": "delete",
"operation_id": null,
"path": "/meal-plans/:Id",
"raises": [],
"request": {
"body": [],
"description": null,
"query": []
},
"response": {
"body": null,
"description": null,
"no_content": true
},
"summary": null,
"tags": []
}
],
"identifier": "meal_plans",
"name": "meal_plans",
"parent_identifiers": [],
"path": "meal-plans",
"resources": [],
"scope": "meal_plan"
}
],
"types": [
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "cooking_step",
"scope": "cooking_step",
"type": "object",
"extends": [],
"shape": [
{
"name": "DurationMinutes",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "Id",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "Instruction",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "StepNumber",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "cooking_step_nested_create_payload",
"scope": "cooking_step",
"type": "object",
"extends": [],
"shape": [
{
"name": "OP",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "literal",
"value": "create"
},
{
"name": "DurationMinutes",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"default": null,
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
},
{
"name": "Instruction",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "StepNumber",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "cooking_step_nested_delete_payload",
"scope": "cooking_step",
"type": "object",
"extends": [],
"shape": [
{
"name": "OP",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "literal",
"value": "delete"
},
{
"name": "Id",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "cooking_step_nested_update_payload",
"scope": "cooking_step",
"type": "object",
"extends": [],
"shape": [
{
"name": "OP",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "literal",
"value": "update"
},
{
"name": "DurationMinutes",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
},
{
"name": "Id",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "Instruction",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "StepNumber",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "error_issue",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "Code",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "Detail",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "Meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "object",
"partial": false,
"shape": []
},
{
"name": "Path",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
}
},
{
"name": "Pointer",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "meal_plan_page",
"scope": "meal_plan",
"type": "object",
"extends": [],
"shape": [
{
"name": "Number",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": 1
},
{
"name": "Size",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": 100,
"min": 1
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "offset_pagination",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "Current",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "Items",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "Next",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "Prev",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "Total",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "cooking_step_nested_payload",
"scope": "cooking_step",
"type": "union",
"discriminator": "OP",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "cooking_step_nested_create_payload",
"tag": "create"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "cooking_step_nested_update_payload",
"tag": "update"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "cooking_step_nested_delete_payload",
"tag": "delete"
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "error",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "Issues",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "error_issue"
}
},
{
"name": "Layer",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "error_layer"
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "meal_plan",
"scope": "meal_plan",
"type": "object",
"extends": [],
"shape": [
{
"name": "CookTime",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "CookingSteps",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "cooking_step"
}
},
{
"name": "CreatedAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
},
{
"name": "Id",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "ServingSize",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "Title",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "UpdatedAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "meal_plan_create_payload",
"scope": "meal_plan",
"type": "object",
"extends": [],
"shape": [
{
"name": "CookTime",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"default": null,
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
},
{
"name": "CookingSteps",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "cooking_step_nested_payload"
}
},
{
"name": "ServingSize",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"default": null,
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
},
{
"name": "Title",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "meal_plan_update_payload",
"scope": "meal_plan",
"type": "object",
"extends": [],
"shape": [
{
"name": "CookTime",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
},
{
"name": "CookingSteps",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "cooking_step_nested_payload"
}
},
{
"name": "ServingSize",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
},
{
"name": "Title",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
}
]
}
]
}Codegen
TypeScript
ts
export type ErrorLayer = 'http' | 'contract' | 'domain';
export interface ErrorIssue {
Code: string;
Detail: string;
Meta: Record<string, unknown>;
Path: string | number[];
Pointer: string;
}
export interface OffsetPagination {
Current: number;
Items: number;
Next?: number | null;
Prev?: number | null;
Total: number;
}
export interface Error {
Issues: ErrorIssue[];
Layer: ErrorLayer;
}ts
export interface CookingStep {
DurationMinutes: number | null;
Id: string;
Instruction: string;
StepNumber: number;
}
export interface CookingStepNestedCreatePayload {
DurationMinutes?: number | null;
Instruction: string;
OP: 'create';
StepNumber: number;
}
export interface CookingStepNestedDeletePayload {
Id: string;
OP: 'delete';
}
export interface CookingStepNestedUpdatePayload {
DurationMinutes?: number | null;
Id?: string;
Instruction?: string;
OP: 'update';
StepNumber?: number;
}
export type CookingStepNestedPayload =
| (CookingStepNestedCreatePayload & { OP: 'create' })
| (CookingStepNestedUpdatePayload & { OP: 'update' })
| (CookingStepNestedDeletePayload & { OP: 'delete' });ts
export * from './cooking-step';
export * from './meal-plan';ts
import type { CookingStep, CookingStepNestedPayload } from './cooking-step';
export interface MealPlanPage {
Number?: number;
Size?: number;
}
export interface MealPlan {
CookingSteps: CookingStep[];
CookTime: number | null;
CreatedAt: string;
Id: string;
ServingSize: number | null;
Title: string;
UpdatedAt: string;
}
export interface MealPlanCreatePayload {
CookingSteps?: CookingStepNestedPayload[];
CookTime?: number | null;
ServingSize?: number | null;
Title: string;
}
export interface MealPlanUpdatePayload {
CookingSteps?: CookingStepNestedPayload[];
CookTime?: number | null;
ServingSize?: number | null;
Title?: string;
}ts
export * from './meal-plans';ts
import type { OffsetPagination } from '../api';
import type {
MealPlan,
MealPlanCreatePayload,
MealPlanPage,
MealPlanUpdatePayload,
} from '../domains/meal-plan';
export type MealPlansIndexMethod = 'GET';
export type MealPlansIndexPath = '/meal-plans';
export interface MealPlansIndexRequestQuery {
Page?: MealPlanPage;
}
export type MealPlansIndexResponseBody = {
MealPlans: MealPlan[];
Meta?: Record<string, unknown>;
Pagination: OffsetPagination;
};
export interface MealPlansIndexRequest {
query: MealPlansIndexRequestQuery;
}
export interface MealPlansIndexResponse {
body: MealPlansIndexResponseBody;
}
export interface MealPlansIndex {
method: MealPlansIndexMethod;
path: MealPlansIndexPath;
request: MealPlansIndexRequest;
response: MealPlansIndexResponse;
}
export type MealPlansShowMethod = 'GET';
export type MealPlansShowPath = '/meal-plans/:Id';
export interface MealPlansShowPathParams {
Id: string;
}
export type MealPlansShowResponseBody = {
MealPlan: MealPlan;
Meta?: Record<string, unknown>;
};
export interface MealPlansShowResponse {
body: MealPlansShowResponseBody;
}
export interface MealPlansShow {
method: MealPlansShowMethod;
path: MealPlansShowPath;
pathParams: MealPlansShowPathParams;
response: MealPlansShowResponse;
}
export type MealPlansCreateMethod = 'POST';
export type MealPlansCreatePath = '/meal-plans';
export interface MealPlansCreateRequestBody {
MealPlan: MealPlanCreatePayload;
}
export type MealPlansCreateResponseBody = {
MealPlan: MealPlan;
Meta?: Record<string, unknown>;
};
export interface MealPlansCreateRequest {
body: MealPlansCreateRequestBody;
}
export interface MealPlansCreateResponse {
body: MealPlansCreateResponseBody;
}
export type MealPlansCreateErrors = 422;
export interface MealPlansCreate {
errors: MealPlansCreateErrors;
method: MealPlansCreateMethod;
path: MealPlansCreatePath;
request: MealPlansCreateRequest;
response: MealPlansCreateResponse;
}
export type MealPlansUpdateMethod = 'PATCH';
export type MealPlansUpdatePath = '/meal-plans/:Id';
export interface MealPlansUpdatePathParams {
Id: string;
}
export interface MealPlansUpdateRequestBody {
MealPlan: MealPlanUpdatePayload;
}
export type MealPlansUpdateResponseBody = {
MealPlan: MealPlan;
Meta?: Record<string, unknown>;
};
export interface MealPlansUpdateRequest {
body: MealPlansUpdateRequestBody;
}
export interface MealPlansUpdateResponse {
body: MealPlansUpdateResponseBody;
}
export type MealPlansUpdateErrors = 422;
export interface MealPlansUpdate {
errors: MealPlansUpdateErrors;
method: MealPlansUpdateMethod;
path: MealPlansUpdatePath;
pathParams: MealPlansUpdatePathParams;
request: MealPlansUpdateRequest;
response: MealPlansUpdateResponse;
}
export type MealPlansDestroyMethod = 'DELETE';
export type MealPlansDestroyPath = '/meal-plans/:Id';
export interface MealPlansDestroyPathParams {
Id: string;
}
export interface MealPlansDestroy {
method: MealPlansDestroyMethod;
path: MealPlansDestroyPath;
pathParams: MealPlansDestroyPathParams;
}Zod
ts
import * as z from 'zod';
export const ErrorLayerSchema = z.enum(['contract', 'domain', 'http']);
export const ErrorIssueSchema = z.object({
Code: z.string(),
Detail: z.string(),
Meta: z.record(z.string(), z.unknown()),
Path: z.array(z.union([z.string(), z.number().int()])),
Pointer: z.string(),
});
export const OffsetPaginationSchema = z.object({
Current: z.number().int(),
Items: z.number().int(),
Next: z.number().int().nullable().optional(),
Prev: z.number().int().nullable().optional(),
Total: z.number().int(),
});
export const ErrorSchema = z.object({
Issues: z.array(ErrorIssueSchema),
Layer: ErrorLayerSchema,
});
export type ErrorLayer = 'contract' | 'domain' | 'http';
export interface ErrorIssue {
Code: string;
Detail: string;
Meta: Record<string, unknown>;
Path: string | number[];
Pointer: string;
}
export interface OffsetPagination {
Current: number;
Items: number;
Next?: number | null;
Prev?: number | null;
Total: number;
}
export interface Error {
Issues: ErrorIssue[];
Layer: ErrorLayer;
}ts
import * as z from 'zod';
export const CookingStepSchema = z.object({
DurationMinutes: z.number().int().nullable(),
Id: z.string(),
Instruction: z.string(),
StepNumber: z.number().int(),
});
export const CookingStepNestedCreatePayloadSchema = z.object({
DurationMinutes: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
Instruction: z.string(),
OP: z.literal('create'),
StepNumber: z.number().int().min(-2147483648).max(2147483647),
});
export const CookingStepNestedDeletePayloadSchema = z.object({
Id: z.string(),
OP: z.literal('delete'),
});
export const CookingStepNestedUpdatePayloadSchema = z.object({
DurationMinutes: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.optional(),
Id: z.string().optional(),
Instruction: z.string().optional(),
OP: z.literal('update'),
StepNumber: z.number().int().min(-2147483648).max(2147483647).optional(),
});
export const CookingStepNestedPayloadSchema = z.discriminatedUnion('OP', [
CookingStepNestedCreatePayloadSchema.extend({ OP: z.literal('create') }),
CookingStepNestedUpdatePayloadSchema.extend({ OP: z.literal('update') }),
CookingStepNestedDeletePayloadSchema.extend({ OP: z.literal('delete') }),
]);
export interface CookingStep {
DurationMinutes: number | null;
Id: string;
Instruction: string;
StepNumber: number;
}
export interface CookingStepNestedCreatePayload {
DurationMinutes?: number | null;
Instruction: string;
OP: 'create';
StepNumber: number;
}
export interface CookingStepNestedDeletePayload {
Id: string;
OP: 'delete';
}
export interface CookingStepNestedUpdatePayload {
DurationMinutes?: number | null;
Id?: string;
Instruction?: string;
OP: 'update';
StepNumber?: number;
}
export type CookingStepNestedPayload =
| (CookingStepNestedCreatePayload & { OP: 'create' })
| (CookingStepNestedUpdatePayload & { OP: 'update' })
| (CookingStepNestedDeletePayload & { OP: 'delete' });ts
export * from './cooking-step';
export * from './meal-plan';ts
import type { CookingStep, CookingStepNestedPayload } from './cooking-step';
import * as z from 'zod';
import {
CookingStepNestedPayloadSchema,
CookingStepSchema,
} from './cooking-step';
export const MealPlanPageSchema = z.object({
Number: z.number().int().min(1).optional(),
Size: z.number().int().min(1).max(100).optional(),
});
export const MealPlanSchema = z.object({
CookingSteps: z.array(CookingStepSchema),
CookTime: z.number().int().nullable(),
CreatedAt: z.iso.datetime(),
Id: z.string(),
ServingSize: z.number().int().nullable(),
Title: z.string(),
UpdatedAt: z.iso.datetime(),
});
export const MealPlanCreatePayloadSchema = z.object({
CookingSteps: z.array(CookingStepNestedPayloadSchema).optional(),
CookTime: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
ServingSize: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
Title: z.string(),
});
export const MealPlanUpdatePayloadSchema = z.object({
CookingSteps: z.array(CookingStepNestedPayloadSchema).optional(),
CookTime: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.optional(),
ServingSize: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.optional(),
Title: z.string().optional(),
});
export interface MealPlanPage {
Number?: number;
Size?: number;
}
export interface MealPlan {
CookingSteps: CookingStep[];
CookTime: number | null;
CreatedAt: string;
Id: string;
ServingSize: number | null;
Title: string;
UpdatedAt: string;
}
export interface MealPlanCreatePayload {
CookingSteps?: CookingStepNestedPayload[];
CookTime?: number | null;
ServingSize?: number | null;
Title: string;
}
export interface MealPlanUpdatePayload {
CookingSteps?: CookingStepNestedPayload[];
CookTime?: number | null;
ServingSize?: number | null;
Title?: string;
}ts
export * from './meal-plans';ts
import type { OffsetPagination } from '../api';
import type {
MealPlan,
MealPlanCreatePayload,
MealPlanPage,
MealPlanUpdatePayload,
} from '../domains/meal-plan';
import * as z from 'zod';
import { OffsetPaginationSchema } from '../api';
import {
MealPlanCreatePayloadSchema,
MealPlanPageSchema,
MealPlanSchema,
MealPlanUpdatePayloadSchema,
} from '../domains/meal-plan';
export const MealPlansIndexRequestQuerySchema = z.object({
Page: MealPlanPageSchema.optional(),
});
export const MealPlansIndexResponseBodySchema = z.object({
MealPlans: z.array(MealPlanSchema),
Meta: z.record(z.string(), z.unknown()).optional(),
Pagination: OffsetPaginationSchema,
});
export const MealPlansShowPathParamsSchema = z.object({ Id: z.string() });
export const MealPlansShowResponseBodySchema = z.object({
MealPlan: MealPlanSchema,
Meta: z.record(z.string(), z.unknown()).optional(),
});
export const MealPlansCreateRequestBodySchema = z.object({
MealPlan: MealPlanCreatePayloadSchema,
});
export const MealPlansCreateResponseBodySchema = z.object({
MealPlan: MealPlanSchema,
Meta: z.record(z.string(), z.unknown()).optional(),
});
export const MealPlansUpdatePathParamsSchema = z.object({ Id: z.string() });
export const MealPlansUpdateRequestBodySchema = z.object({
MealPlan: MealPlanUpdatePayloadSchema,
});
export const MealPlansUpdateResponseBodySchema = z.object({
MealPlan: MealPlanSchema,
Meta: z.record(z.string(), z.unknown()).optional(),
});
export const MealPlansDestroyPathParamsSchema = z.object({ Id: z.string() });
export type MealPlansIndexMethod = 'GET';
export type MealPlansIndexPath = '/meal-plans';
export interface MealPlansIndexRequestQuery {
Page?: MealPlanPage;
}
export type MealPlansIndexResponseBody = {
MealPlans: MealPlan[];
Meta?: Record<string, unknown>;
Pagination: OffsetPagination;
};
export interface MealPlansIndexRequest {
query: MealPlansIndexRequestQuery;
}
export interface MealPlansIndexResponse {
body: MealPlansIndexResponseBody;
}
export interface MealPlansIndex {
method: MealPlansIndexMethod;
path: MealPlansIndexPath;
request: MealPlansIndexRequest;
response: MealPlansIndexResponse;
}
export type MealPlansShowMethod = 'GET';
export type MealPlansShowPath = '/meal-plans/:Id';
export interface MealPlansShowPathParams {
Id: string;
}
export type MealPlansShowResponseBody = {
MealPlan: MealPlan;
Meta?: Record<string, unknown>;
};
export interface MealPlansShowResponse {
body: MealPlansShowResponseBody;
}
export interface MealPlansShow {
method: MealPlansShowMethod;
path: MealPlansShowPath;
pathParams: MealPlansShowPathParams;
response: MealPlansShowResponse;
}
export type MealPlansCreateMethod = 'POST';
export type MealPlansCreatePath = '/meal-plans';
export interface MealPlansCreateRequestBody {
MealPlan: MealPlanCreatePayload;
}
export type MealPlansCreateResponseBody = {
MealPlan: MealPlan;
Meta?: Record<string, unknown>;
};
export interface MealPlansCreateRequest {
body: MealPlansCreateRequestBody;
}
export interface MealPlansCreateResponse {
body: MealPlansCreateResponseBody;
}
export type MealPlansCreateErrors = 422;
export interface MealPlansCreate {
errors: MealPlansCreateErrors;
method: MealPlansCreateMethod;
path: MealPlansCreatePath;
request: MealPlansCreateRequest;
response: MealPlansCreateResponse;
}
export type MealPlansUpdateMethod = 'PATCH';
export type MealPlansUpdatePath = '/meal-plans/:Id';
export interface MealPlansUpdatePathParams {
Id: string;
}
export interface MealPlansUpdateRequestBody {
MealPlan: MealPlanUpdatePayload;
}
export type MealPlansUpdateResponseBody = {
MealPlan: MealPlan;
Meta?: Record<string, unknown>;
};
export interface MealPlansUpdateRequest {
body: MealPlansUpdateRequestBody;
}
export interface MealPlansUpdateResponse {
body: MealPlansUpdateResponseBody;
}
export type MealPlansUpdateErrors = 422;
export interface MealPlansUpdate {
errors: MealPlansUpdateErrors;
method: MealPlansUpdateMethod;
path: MealPlansUpdatePath;
pathParams: MealPlansUpdatePathParams;
request: MealPlansUpdateRequest;
response: MealPlansUpdateResponse;
}
export type MealPlansDestroyMethod = 'DELETE';
export type MealPlansDestroyPath = '/meal-plans/:Id';
export interface MealPlansDestroyPathParams {
Id: string;
}
export interface MealPlansDestroy {
method: MealPlansDestroyMethod;
path: MealPlansDestroyPath;
pathParams: MealPlansDestroyPathParams;
}Sorbus
ts
import * as z from 'zod';
export const ErrorLayerSchema = z.enum(['contract', 'domain', 'http']);
export const ErrorIssueSchema = z.object({
Code: z.string(),
Detail: z.string(),
Meta: z.record(z.string(), z.unknown()),
Path: z.array(z.union([z.string(), z.number().int()])),
Pointer: z.string(),
});
export const OffsetPaginationSchema = z.object({
Current: z.number().int(),
Items: z.number().int(),
Next: z.number().int().nullable().optional(),
Prev: z.number().int().nullable().optional(),
Total: z.number().int(),
});
export const ErrorSchema = z.object({
Issues: z.array(ErrorIssueSchema),
Layer: ErrorLayerSchema,
});
export type ErrorLayer = 'contract' | 'domain' | 'http';
export interface ErrorIssue {
Code: string;
Detail: string;
Meta: Record<string, unknown>;
Path: string | number[];
Pointer: string;
}
export interface OffsetPagination {
Current: number;
Items: number;
Next?: number | null;
Prev?: number | null;
Total: number;
}
export interface Error {
Issues: ErrorIssue[];
Layer: ErrorLayer;
}ts
import type { MealPlansOperationTree } from './endpoints';
import { createClientFactory } from 'sorbus';
import { contract } from './contract';
export interface Client {
mealPlans: MealPlansOperationTree;
}
export const createClient = createClientFactory<Client>(contract);ts
import { ErrorSchema } from './api';
import { mealPlans } from './endpoints';
export const contract = {
endpoints: {
mealPlans,
},
error: ErrorSchema,
} as const;ts
import * as z from 'zod';
export const CookingStepSchema = z.object({
DurationMinutes: z.number().int().nullable(),
Id: z.string(),
Instruction: z.string(),
StepNumber: z.number().int(),
});
export const CookingStepNestedCreatePayloadSchema = z.object({
DurationMinutes: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
Instruction: z.string(),
OP: z.literal('create'),
StepNumber: z.number().int().min(-2147483648).max(2147483647),
});
export const CookingStepNestedDeletePayloadSchema = z.object({
Id: z.string(),
OP: z.literal('delete'),
});
export const CookingStepNestedUpdatePayloadSchema = z.object({
DurationMinutes: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.optional(),
Id: z.string().optional(),
Instruction: z.string().optional(),
OP: z.literal('update'),
StepNumber: z.number().int().min(-2147483648).max(2147483647).optional(),
});
export const CookingStepNestedPayloadSchema = z.discriminatedUnion('OP', [
CookingStepNestedCreatePayloadSchema.extend({ OP: z.literal('create') }),
CookingStepNestedUpdatePayloadSchema.extend({ OP: z.literal('update') }),
CookingStepNestedDeletePayloadSchema.extend({ OP: z.literal('delete') }),
]);
export interface CookingStep {
DurationMinutes: number | null;
Id: string;
Instruction: string;
StepNumber: number;
}
export interface CookingStepNestedCreatePayload {
DurationMinutes?: number | null;
Instruction: string;
OP: 'create';
StepNumber: number;
}
export interface CookingStepNestedDeletePayload {
Id: string;
OP: 'delete';
}
export interface CookingStepNestedUpdatePayload {
DurationMinutes?: number | null;
Id?: string;
Instruction?: string;
OP: 'update';
StepNumber?: number;
}
export type CookingStepNestedPayload =
| (CookingStepNestedCreatePayload & { OP: 'create' })
| (CookingStepNestedUpdatePayload & { OP: 'update' })
| (CookingStepNestedDeletePayload & { OP: 'delete' });ts
export * from './cooking-step';
export * from './meal-plan';ts
import type { CookingStep, CookingStepNestedPayload } from './cooking-step';
import * as z from 'zod';
import {
CookingStepNestedPayloadSchema,
CookingStepSchema,
} from './cooking-step';
export const MealPlanPageSchema = z.object({
Number: z.number().int().min(1).optional(),
Size: z.number().int().min(1).max(100).optional(),
});
export const MealPlanSchema = z.object({
CookingSteps: z.array(CookingStepSchema),
CookTime: z.number().int().nullable(),
CreatedAt: z.iso.datetime(),
Id: z.string(),
ServingSize: z.number().int().nullable(),
Title: z.string(),
UpdatedAt: z.iso.datetime(),
});
export const MealPlanCreatePayloadSchema = z.object({
CookingSteps: z.array(CookingStepNestedPayloadSchema).optional(),
CookTime: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
ServingSize: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
Title: z.string(),
});
export const MealPlanUpdatePayloadSchema = z.object({
CookingSteps: z.array(CookingStepNestedPayloadSchema).optional(),
CookTime: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.optional(),
ServingSize: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.optional(),
Title: z.string().optional(),
});
export interface MealPlanPage {
Number?: number;
Size?: number;
}
export interface MealPlan {
CookingSteps: CookingStep[];
CookTime: number | null;
CreatedAt: string;
Id: string;
ServingSize: number | null;
Title: string;
UpdatedAt: string;
}
export interface MealPlanCreatePayload {
CookingSteps?: CookingStepNestedPayload[];
CookTime?: number | null;
ServingSize?: number | null;
Title: string;
}
export interface MealPlanUpdatePayload {
CookingSteps?: CookingStepNestedPayload[];
CookTime?: number | null;
ServingSize?: number | null;
Title?: string;
}ts
export * from './meal-plans';ts
import type { Operation } from 'sorbus';
import type { OffsetPagination } from '../api';
import type {
MealPlan,
MealPlanCreatePayload,
MealPlanPage,
MealPlanUpdatePayload,
} from '../domains/meal-plan';
import * as z from 'zod';
import { OffsetPaginationSchema } from '../api';
import {
MealPlanCreatePayloadSchema,
MealPlanPageSchema,
MealPlanSchema,
MealPlanUpdatePayloadSchema,
} from '../domains/meal-plan';
export const MealPlansIndexRequestQuerySchema = z.object({
Page: MealPlanPageSchema.optional(),
});
export const MealPlansIndexResponseBodySchema = z.object({
MealPlans: z.array(MealPlanSchema),
Meta: z.record(z.string(), z.unknown()).optional(),
Pagination: OffsetPaginationSchema,
});
export const MealPlansShowPathParamsSchema = z.object({ Id: z.string() });
export const MealPlansShowResponseBodySchema = z.object({
MealPlan: MealPlanSchema,
Meta: z.record(z.string(), z.unknown()).optional(),
});
export const MealPlansCreateRequestBodySchema = z.object({
MealPlan: MealPlanCreatePayloadSchema,
});
export const MealPlansCreateResponseBodySchema = z.object({
MealPlan: MealPlanSchema,
Meta: z.record(z.string(), z.unknown()).optional(),
});
export const MealPlansUpdatePathParamsSchema = z.object({ Id: z.string() });
export const MealPlansUpdateRequestBodySchema = z.object({
MealPlan: MealPlanUpdatePayloadSchema,
});
export const MealPlansUpdateResponseBodySchema = z.object({
MealPlan: MealPlanSchema,
Meta: z.record(z.string(), z.unknown()).optional(),
});
export const MealPlansDestroyPathParamsSchema = z.object({ Id: z.string() });
export type MealPlansIndexMethod = 'GET';
export type MealPlansIndexPath = '/meal-plans';
export interface MealPlansIndexRequestQuery {
Page?: MealPlanPage;
}
export type MealPlansIndexResponseBody = {
MealPlans: MealPlan[];
Meta?: Record<string, unknown>;
Pagination: OffsetPagination;
};
export interface MealPlansIndexRequest {
query: MealPlansIndexRequestQuery;
}
export interface MealPlansIndexResponse {
body: MealPlansIndexResponseBody;
}
export interface MealPlansIndex {
method: MealPlansIndexMethod;
path: MealPlansIndexPath;
request: MealPlansIndexRequest;
response: MealPlansIndexResponse;
}
export type MealPlansShowMethod = 'GET';
export type MealPlansShowPath = '/meal-plans/:Id';
export interface MealPlansShowPathParams {
Id: string;
}
export type MealPlansShowResponseBody = {
MealPlan: MealPlan;
Meta?: Record<string, unknown>;
};
export interface MealPlansShowResponse {
body: MealPlansShowResponseBody;
}
export interface MealPlansShow {
method: MealPlansShowMethod;
path: MealPlansShowPath;
pathParams: MealPlansShowPathParams;
response: MealPlansShowResponse;
}
export type MealPlansCreateMethod = 'POST';
export type MealPlansCreatePath = '/meal-plans';
export interface MealPlansCreateRequestBody {
MealPlan: MealPlanCreatePayload;
}
export type MealPlansCreateResponseBody = {
MealPlan: MealPlan;
Meta?: Record<string, unknown>;
};
export interface MealPlansCreateRequest {
body: MealPlansCreateRequestBody;
}
export interface MealPlansCreateResponse {
body: MealPlansCreateResponseBody;
}
export type MealPlansCreateErrors = 422;
export interface MealPlansCreate {
errors: MealPlansCreateErrors;
method: MealPlansCreateMethod;
path: MealPlansCreatePath;
request: MealPlansCreateRequest;
response: MealPlansCreateResponse;
}
export type MealPlansUpdateMethod = 'PATCH';
export type MealPlansUpdatePath = '/meal-plans/:Id';
export interface MealPlansUpdatePathParams {
Id: string;
}
export interface MealPlansUpdateRequestBody {
MealPlan: MealPlanUpdatePayload;
}
export type MealPlansUpdateResponseBody = {
MealPlan: MealPlan;
Meta?: Record<string, unknown>;
};
export interface MealPlansUpdateRequest {
body: MealPlansUpdateRequestBody;
}
export interface MealPlansUpdateResponse {
body: MealPlansUpdateResponseBody;
}
export type MealPlansUpdateErrors = 422;
export interface MealPlansUpdate {
errors: MealPlansUpdateErrors;
method: MealPlansUpdateMethod;
path: MealPlansUpdatePath;
pathParams: MealPlansUpdatePathParams;
request: MealPlansUpdateRequest;
response: MealPlansUpdateResponse;
}
export type MealPlansDestroyMethod = 'DELETE';
export type MealPlansDestroyPath = '/meal-plans/:Id';
export interface MealPlansDestroyPathParams {
Id: string;
}
export interface MealPlansDestroy {
method: MealPlansDestroyMethod;
path: MealPlansDestroyPath;
pathParams: MealPlansDestroyPathParams;
}
export const mealPlans = {
create: {
errors: [422],
method: 'POST',
path: '/meal-plans',
request: {
body: MealPlansCreateRequestBodySchema,
},
response: {
body: MealPlansCreateResponseBodySchema,
},
},
destroy: {
method: 'DELETE',
path: '/meal-plans/:Id',
pathParams: MealPlansDestroyPathParamsSchema,
},
index: {
method: 'GET',
path: '/meal-plans',
request: {
query: MealPlansIndexRequestQuerySchema,
},
response: {
body: MealPlansIndexResponseBodySchema,
},
},
show: {
method: 'GET',
path: '/meal-plans/:Id',
pathParams: MealPlansShowPathParamsSchema,
response: {
body: MealPlansShowResponseBodySchema,
},
},
update: {
errors: [422],
method: 'PATCH',
path: '/meal-plans/:Id',
pathParams: MealPlansUpdatePathParamsSchema,
request: {
body: MealPlansUpdateRequestBodySchema,
},
response: {
body: MealPlansUpdateResponseBodySchema,
},
},
} as const;
export interface MealPlansOperationTree {
create: Operation<MealPlansCreate>;
destroy: Operation<MealPlansDestroy>;
index: Operation<MealPlansIndex>;
show: Operation<MealPlansShow>;
update: Operation<MealPlansUpdate>;
}