Nested Saves
Create, update, and delete nested records in a single request
API Definition
config/apis/clever_rabbit.rb
rb
# frozen_string_literal: true
Apiwork::API.define '/clever_rabbit' do
key_format :camel
export :openapi
export :typescript
export :zod
resources :orders
endModels
app/models/clever_rabbit/order.rb
rb
# frozen_string_literal: true
module CleverRabbit
class Order < ApplicationRecord
has_many :line_items, dependent: :destroy
has_one :shipping_address, dependent: :destroy
accepts_nested_attributes_for :line_items, allow_destroy: true
accepts_nested_attributes_for :shipping_address, allow_destroy: true
validates :order_number, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| created_at | datetime | ||
| order_number | string | ||
| status | string | ✓ | pending |
| total | decimal | ✓ | |
| updated_at | datetime |
app/models/clever_rabbit/line_item.rb
rb
# frozen_string_literal: true
module CleverRabbit
class LineItem < ApplicationRecord
belongs_to :order
validates :product_name, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| created_at | datetime | ||
| order_id | string | ||
| product_name | string | ||
| quantity | integer | ✓ | 1 |
| unit_price | decimal | ✓ | |
| updated_at | datetime |
app/models/clever_rabbit/shipping_address.rb
rb
# frozen_string_literal: true
module CleverRabbit
class ShippingAddress < ApplicationRecord
belongs_to :order
validates :street, :city, :postal_code, :country, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| city | string | ||
| country | string | ||
| created_at | datetime | ||
| order_id | string | ||
| postal_code | string | ||
| street | string | ||
| updated_at | datetime |
Representations
app/representations/clever_rabbit/order_representation.rb
rb
# frozen_string_literal: true
module CleverRabbit
class OrderRepresentation < Apiwork::Representation::Base
attribute :id
attribute :order_number, writable: true
attribute :status
attribute :total
attribute :created_at
attribute :updated_at
has_many :line_items, include: :always, writable: true
has_one :shipping_address, include: :always, writable: true
end
endapp/representations/clever_rabbit/line_item_representation.rb
rb
# frozen_string_literal: true
module CleverRabbit
class LineItemRepresentation < Apiwork::Representation::Base
attribute :id
attribute :product_name, writable: true
attribute :quantity, writable: true
attribute :unit_price, writable: true
end
endapp/representations/clever_rabbit/shipping_address_representation.rb
rb
# frozen_string_literal: true
module CleverRabbit
class ShippingAddressRepresentation < Apiwork::Representation::Base
attribute :id
attribute :street, writable: true
attribute :city, writable: true
attribute :postal_code, writable: true
attribute :country, writable: true
end
endContracts
app/contracts/clever_rabbit/order_contract.rb
rb
# frozen_string_literal: true
module CleverRabbit
class OrderContract < Apiwork::Contract::Base
representation OrderRepresentation
end
endControllers
app/controllers/clever_rabbit/orders_controller.rb
rb
# frozen_string_literal: true
module CleverRabbit
class OrdersController < ApplicationController
before_action :set_order, only: %i[show update destroy]
def index
orders = Order.all
expose orders
end
def show
expose order
end
def create
order = Order.create(contract.body[:order])
expose order
end
def update
order.update(contract.body[:order])
expose order
end
def destroy
order.destroy
expose order
end
private
attr_reader :order
def set_order
@order = Order.find(params[:id])
end
end
endRequest Examples
List all orders
Request
http
GET /clever_rabbit/ordersResponse 200
json
{
"orders": [
{
"id": "38948b8f-2c00-5384-8f16-b1105fcd31fb",
"orderNumber": "ORD-001",
"status": "pending",
"total": null,
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z",
"lineItems": [],
"shippingAddress": null
},
{
"id": "4c65a30e-5d9c-5523-b6bd-25e85ed94165",
"orderNumber": "ORD-002",
"status": "pending",
"total": null,
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z",
"lineItems": [],
"shippingAddress": null
}
],
"pagination": {
"items": 2,
"total": 1,
"current": 1,
"next": null,
"prev": null
}
}Get order details
Request
http
GET /clever_rabbit/orders/38948b8f-2c00-5384-8f16-b1105fcd31fbResponse 200
json
{
"order": {
"id": "38948b8f-2c00-5384-8f16-b1105fcd31fb",
"orderNumber": "ORD-001",
"status": "pending",
"total": null,
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z",
"lineItems": [],
"shippingAddress": null
}
}Create order with nested records
Request
http
POST /clever_rabbit/orders
Content-Type: application/json
{
"order": {
"orderNumber": "ORD-001",
"lineItems": [
{
"productName": "Widget",
"quantity": 2,
"unitPrice": 29.99
},
{
"productName": "Gadget",
"quantity": 1,
"unitPrice": 49.99
}
],
"shippingAddress": {
"street": "123 Main St",
"city": "Springfield",
"postalCode": "12345",
"country": "USA"
}
}
}Response 201
json
{
"order": {
"id": "38948b8f-2c00-5384-8f16-b1105fcd31fb",
"orderNumber": "ORD-001",
"status": "pending",
"total": null,
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z",
"lineItems": [
{
"id": "ad73acbb-0926-5060-9b75-5888bde61fc7",
"productName": "Widget",
"quantity": 2,
"unitPrice": "29.99"
},
{
"id": "987c1624-9b7b-5467-910c-4dc0035b91ee",
"productName": "Gadget",
"quantity": 1,
"unitPrice": "49.99"
}
],
"shippingAddress": {
"id": "3cb3bbd4-ed44-5c37-a3bf-f77ea95a7e5a",
"street": "123 Main St",
"city": "Springfield",
"postalCode": "12345",
"country": "USA"
}
}
}Update order with new items
Request
http
PATCH /clever_rabbit/orders/38948b8f-2c00-5384-8f16-b1105fcd31fb
Content-Type: application/json
{
"order": {
"lineItems": [
{
"productName": "New Item",
"quantity": 3,
"unitPrice": 19.99
}
]
}
}Response 200
json
{
"order": {
"id": "38948b8f-2c00-5384-8f16-b1105fcd31fb",
"orderNumber": "ORD-001",
"status": "pending",
"total": null,
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z",
"lineItems": [
{
"id": "ad73acbb-0926-5060-9b75-5888bde61fc7",
"productName": "New Item",
"quantity": 3,
"unitPrice": "19.99"
}
],
"shippingAddress": null
}
}Delete an order
Request
http
DELETE /clever_rabbit/orders/38948b8f-2c00-5384-8f16-b1105fcd31fbResponse 204
Remove nested record
Request
http
PATCH /clever_rabbit/orders/38948b8f-2c00-5384-8f16-b1105fcd31fb
Content-Type: application/json
{
"order": {
"lineItems": [
{
"OP": "delete",
"id": "987c1624-9b7b-5467-910c-4dc0035b91ee"
}
]
}
}Response 200
json
{
"order": {
"id": "38948b8f-2c00-5384-8f16-b1105fcd31fb",
"orderNumber": "ORD-001",
"status": "pending",
"total": null,
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z",
"lineItems": [
{
"id": "ad73acbb-0926-5060-9b75-5888bde61fc7",
"productName": "Widget to Keep",
"quantity": 2,
"unitPrice": "19.99"
}
],
"shippingAddress": null
}
}Generated Output
Introspection
json
{
"base_path": "/clever_rabbit",
"enums": {
"layer": {
"deprecated": false,
"description": null,
"example": null,
"values": [
"http",
"contract",
"domain"
]
}
},
"error_codes": {
"unprocessable_entity": {
"description": "Unprocessable Entity",
"status": 422
}
},
"info": null,
"resources": {
"orders": {
"actions": {
"index": {
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/orders",
"raises": [],
"request": {
"body": {},
"query": {
"page": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "order_page"
}
}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "order_index_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": null,
"tags": []
},
"show": {
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/orders/:id",
"raises": [],
"request": {
"body": {},
"query": {}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "order_show_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": null,
"tags": []
},
"create": {
"deprecated": false,
"description": null,
"method": "post",
"operation_id": null,
"path": "/orders",
"raises": [
"unprocessable_entity"
],
"request": {
"body": {
"order": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "order_create_payload"
}
},
"query": {}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "order_create_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": null,
"tags": []
},
"update": {
"deprecated": false,
"description": null,
"method": "patch",
"operation_id": null,
"path": "/orders/:id",
"raises": [
"unprocessable_entity"
],
"request": {
"body": {
"order": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "order_update_payload"
}
},
"query": {}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "order_update_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": null,
"tags": []
},
"destroy": {
"deprecated": false,
"description": null,
"method": "delete",
"operation_id": null,
"path": "/orders/:id",
"raises": [],
"request": {
"body": {},
"query": {}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": null
},
"no_content": true
},
"summary": null,
"tags": []
}
},
"identifier": "orders",
"parent_identifiers": [],
"path": "orders",
"resources": {}
}
},
"types": {
"error": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"issues": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "issue"
},
"shape": {}
},
"layer": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "layer"
}
},
"type": "object",
"variants": []
},
"error_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [
"error"
],
"shape": {},
"type": "object",
"variants": []
},
"issue": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"code": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"detail": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "object",
"partial": false,
"shape": {}
},
"path": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shape": {}
},
"pointer": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"line_item": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"id": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"product_name": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"quantity": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": false,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"unit_price": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": false,
"type": "decimal",
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"line_item_create_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"product_name": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"quantity": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"unit_price": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "decimal",
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"line_item_nested_create_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"OP": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "literal",
"value": "create"
},
"product_name": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"quantity": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"unit_price": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "decimal",
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"line_item_nested_delete_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"OP": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "literal",
"value": "delete"
},
"id": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"line_item_nested_payload": {
"deprecated": false,
"description": null,
"discriminator": "OP",
"example": null,
"extends": [],
"shape": {},
"type": "union",
"variants": [
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "line_item_nested_create_payload"
},
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "line_item_nested_update_payload"
},
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "line_item_nested_delete_payload"
}
]
},
"line_item_nested_update_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"OP": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "literal",
"value": "update"
},
"id": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"product_name": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"quantity": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"unit_price": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "decimal",
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"line_item_update_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"product_name": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"quantity": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"unit_price": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "decimal",
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"offset_pagination": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"current": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"items": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"next": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"prev": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"total": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "integer",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"order": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"created_at": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "datetime"
},
"id": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"line_items": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "line_item"
},
"shape": {}
},
"order_number": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_address": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "shipping_address"
},
"status": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"total": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": false,
"type": "decimal",
"max": null,
"min": null
},
"updated_at": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "datetime"
}
},
"type": "object",
"variants": []
},
"order_create_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"line_items": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "line_item_nested_payload"
},
"shape": {}
},
"order_number": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_address": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "shipping_address_nested_payload"
}
},
"type": "object",
"variants": []
},
"order_create_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
},
"order": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "order"
}
},
"type": "object",
"variants": []
},
"order_index_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"pagination": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "offset_pagination"
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
},
"orders": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "order"
},
"shape": {}
}
},
"type": "object",
"variants": []
},
"order_page": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"number": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "integer",
"format": null,
"max": null,
"min": 1
},
"size": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "integer",
"format": null,
"max": 100,
"min": 1
}
},
"type": "object",
"variants": []
},
"order_show_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
},
"order": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "order"
}
},
"type": "object",
"variants": []
},
"order_update_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"line_items": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "line_item_nested_payload"
},
"shape": {}
},
"order_number": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_address": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "shipping_address_nested_payload"
}
},
"type": "object",
"variants": []
},
"order_update_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
},
"order": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "order"
}
},
"type": "object",
"variants": []
},
"shipping_address": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"city": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"country": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"id": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"postal_code": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"shipping_address_create_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"city": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"country": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"postal_code": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"shipping_address_nested_create_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"OP": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "literal",
"value": "create"
},
"city": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"country": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"postal_code": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"shipping_address_nested_delete_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"OP": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "literal",
"value": "delete"
},
"id": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"shipping_address_nested_payload": {
"deprecated": false,
"description": null,
"discriminator": "OP",
"example": null,
"extends": [],
"shape": {},
"type": "union",
"variants": [
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "shipping_address_nested_create_payload"
},
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "shipping_address_nested_update_payload"
},
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "shipping_address_nested_delete_payload"
}
]
},
"shipping_address_nested_update_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"OP": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "literal",
"value": "update"
},
"city": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"country": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"id": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"postal_code": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"shipping_address_update_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"city": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"country": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"postal_code": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
}
}
}TypeScript
ts
export interface Error {
issues: Issue[];
layer: Layer;
}
export type ErrorResponseBody = Error;
export interface Issue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string[];
pointer: string;
}
export type Layer = 'contract' | 'domain' | 'http';
export interface LineItem {
id: string;
productName: string;
quantity: null | number;
unitPrice: null | number;
}
export interface LineItemNestedCreatePayload {
OP?: 'create';
productName: string;
quantity?: null | number;
unitPrice?: null | number;
}
export interface LineItemNestedDeletePayload {
OP?: 'delete';
id: string;
}
export type LineItemNestedPayload = LineItemNestedCreatePayload | LineItemNestedUpdatePayload | LineItemNestedDeletePayload;
export interface LineItemNestedUpdatePayload {
OP?: 'update';
id?: string;
productName?: string;
quantity?: null | number;
unitPrice?: null | number;
}
export interface OffsetPagination {
current: number;
items: number;
next?: null | number;
prev?: null | number;
total: number;
}
export interface Order {
createdAt: string;
id: string;
lineItems: LineItem[];
orderNumber: string;
shippingAddress: ShippingAddress;
status: null | string;
total: null | number;
updatedAt: string;
}
export interface OrderCreatePayload {
lineItems?: LineItemNestedPayload[];
orderNumber: string;
shippingAddress?: ShippingAddressNestedPayload;
}
export interface OrderCreateSuccessResponseBody {
meta?: Record<string, unknown>;
order: Order;
}
export interface OrderIndexSuccessResponseBody {
meta?: Record<string, unknown>;
orders: Order[];
pagination: OffsetPagination;
}
export interface OrderPage {
number?: number;
size?: number;
}
export interface OrderShowSuccessResponseBody {
meta?: Record<string, unknown>;
order: Order;
}
export interface OrderUpdatePayload {
lineItems?: LineItemNestedPayload[];
orderNumber?: string;
shippingAddress?: ShippingAddressNestedPayload;
}
export interface OrderUpdateSuccessResponseBody {
meta?: Record<string, unknown>;
order: Order;
}
export interface OrdersCreateRequest {
body: OrdersCreateRequestBody;
}
export interface OrdersCreateRequestBody {
order: OrderCreatePayload;
}
export interface OrdersCreateResponse {
body: OrdersCreateResponseBody;
}
export type OrdersCreateResponseBody = ErrorResponseBody | OrderCreateSuccessResponseBody;
export type OrdersDestroyResponse = never;
export interface OrdersIndexRequest {
query: OrdersIndexRequestQuery;
}
export interface OrdersIndexRequestQuery {
page?: OrderPage;
}
export interface OrdersIndexResponse {
body: OrdersIndexResponseBody;
}
export type OrdersIndexResponseBody = ErrorResponseBody | OrderIndexSuccessResponseBody;
export interface OrdersShowResponse {
body: OrdersShowResponseBody;
}
export type OrdersShowResponseBody = ErrorResponseBody | OrderShowSuccessResponseBody;
export interface OrdersUpdateRequest {
body: OrdersUpdateRequestBody;
}
export interface OrdersUpdateRequestBody {
order: OrderUpdatePayload;
}
export interface OrdersUpdateResponse {
body: OrdersUpdateResponseBody;
}
export type OrdersUpdateResponseBody = ErrorResponseBody | OrderUpdateSuccessResponseBody;
export interface ShippingAddress {
city: string;
country: string;
id: string;
postalCode: string;
street: string;
}
export interface ShippingAddressNestedCreatePayload {
OP?: 'create';
city: string;
country: string;
postalCode: string;
street: string;
}
export interface ShippingAddressNestedDeletePayload {
OP?: 'delete';
id: string;
}
export type ShippingAddressNestedPayload = ShippingAddressNestedCreatePayload | ShippingAddressNestedUpdatePayload | ShippingAddressNestedDeletePayload;
export interface ShippingAddressNestedUpdatePayload {
OP?: 'update';
city?: string;
country?: string;
id?: string;
postalCode?: string;
street?: string;
}Zod
ts
import { z } from 'zod';
export const LayerSchema = z.enum(['contract', 'domain', 'http']);
export const IssueSchema = z.object({
code: z.string(),
detail: z.string(),
meta: z.record(z.string(), z.unknown()),
path: z.array(z.string()),
pointer: z.string()
});
export const LineItemSchema = z.object({
id: z.string(),
productName: z.string(),
quantity: z.number().int().nullable(),
unitPrice: z.number().nullable()
});
export const LineItemNestedCreatePayloadSchema = z.object({
OP: z.literal('create').optional(),
productName: z.string(),
quantity: z.number().int().nullable().optional(),
unitPrice: z.number().nullable().optional()
});
export const LineItemNestedDeletePayloadSchema = z.object({
OP: z.literal('delete').optional(),
id: z.string()
});
export const LineItemNestedUpdatePayloadSchema = z.object({
OP: z.literal('update').optional(),
id: z.string().optional(),
productName: z.string().optional(),
quantity: z.number().int().nullable().optional(),
unitPrice: z.number().nullable().optional()
});
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 OrderPageSchema = z.object({
number: z.number().int().min(1).optional(),
size: z.number().int().min(1).max(100).optional()
});
export const ShippingAddressSchema = z.object({
city: z.string(),
country: z.string(),
id: z.string(),
postalCode: z.string(),
street: z.string()
});
export const ShippingAddressNestedCreatePayloadSchema = z.object({
OP: z.literal('create').optional(),
city: z.string(),
country: z.string(),
postalCode: z.string(),
street: z.string()
});
export const ShippingAddressNestedDeletePayloadSchema = z.object({
OP: z.literal('delete').optional(),
id: z.string()
});
export const ShippingAddressNestedUpdatePayloadSchema = z.object({
OP: z.literal('update').optional(),
city: z.string().optional(),
country: z.string().optional(),
id: z.string().optional(),
postalCode: z.string().optional(),
street: z.string().optional()
});
export const ErrorSchema = z.object({
issues: z.array(IssueSchema),
layer: LayerSchema
});
export const LineItemNestedPayloadSchema = z.discriminatedUnion('OP', [
LineItemNestedCreatePayloadSchema,
LineItemNestedUpdatePayloadSchema,
LineItemNestedDeletePayloadSchema
]);
export const OrderSchema = z.object({
createdAt: z.iso.datetime(),
id: z.string(),
lineItems: z.array(LineItemSchema),
orderNumber: z.string(),
shippingAddress: ShippingAddressSchema,
status: z.string().nullable(),
total: z.number().nullable(),
updatedAt: z.iso.datetime()
});
export const ShippingAddressNestedPayloadSchema = z.discriminatedUnion('OP', [
ShippingAddressNestedCreatePayloadSchema,
ShippingAddressNestedUpdatePayloadSchema,
ShippingAddressNestedDeletePayloadSchema
]);
export const ErrorResponseBodySchema = ErrorSchema;
export const OrderCreatePayloadSchema = z.object({
lineItems: z.array(LineItemNestedPayloadSchema).optional(),
orderNumber: z.string(),
shippingAddress: ShippingAddressNestedPayloadSchema.optional()
});
export const OrderCreateSuccessResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
order: OrderSchema
});
export const OrderIndexSuccessResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
orders: z.array(OrderSchema),
pagination: OffsetPaginationSchema
});
export const OrderShowSuccessResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
order: OrderSchema
});
export const OrderUpdatePayloadSchema = z.object({
lineItems: z.array(LineItemNestedPayloadSchema).optional(),
orderNumber: z.string().optional(),
shippingAddress: ShippingAddressNestedPayloadSchema.optional()
});
export const OrderUpdateSuccessResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
order: OrderSchema
});
export const OrdersIndexRequestQuerySchema = z.object({
page: OrderPageSchema.optional()
});
export const OrdersIndexRequestSchema = z.object({
query: OrdersIndexRequestQuerySchema
});
export const OrdersIndexResponseBodySchema = z.union([OrderIndexSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const OrdersIndexResponseSchema = z.object({
body: OrdersIndexResponseBodySchema
});
export const OrdersShowResponseBodySchema = z.union([OrderShowSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const OrdersShowResponseSchema = z.object({
body: OrdersShowResponseBodySchema
});
export const OrdersCreateRequestBodySchema = z.object({
order: OrderCreatePayloadSchema
});
export const OrdersCreateRequestSchema = z.object({
body: OrdersCreateRequestBodySchema
});
export const OrdersCreateResponseBodySchema = z.union([OrderCreateSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const OrdersCreateResponseSchema = z.object({
body: OrdersCreateResponseBodySchema
});
export const OrdersUpdateRequestBodySchema = z.object({
order: OrderUpdatePayloadSchema
});
export const OrdersUpdateRequestSchema = z.object({
body: OrdersUpdateRequestBodySchema
});
export const OrdersUpdateResponseBodySchema = z.union([OrderUpdateSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const OrdersUpdateResponseSchema = z.object({
body: OrdersUpdateResponseBodySchema
});
export const OrdersDestroyResponseSchema = z.never();
export interface Error {
issues: Issue[];
layer: Layer;
}
export type ErrorResponseBody = Error;
export interface Issue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string[];
pointer: string;
}
export type Layer = 'contract' | 'domain' | 'http';
export interface LineItem {
id: string;
productName: string;
quantity: null | number;
unitPrice: null | number;
}
export interface LineItemNestedCreatePayload {
OP?: 'create';
productName: string;
quantity?: null | number;
unitPrice?: null | number;
}
export interface LineItemNestedDeletePayload {
OP?: 'delete';
id: string;
}
export type LineItemNestedPayload = LineItemNestedCreatePayload | LineItemNestedUpdatePayload | LineItemNestedDeletePayload;
export interface LineItemNestedUpdatePayload {
OP?: 'update';
id?: string;
productName?: string;
quantity?: null | number;
unitPrice?: null | number;
}
export interface OffsetPagination {
current: number;
items: number;
next?: null | number;
prev?: null | number;
total: number;
}
export interface Order {
createdAt: string;
id: string;
lineItems: LineItem[];
orderNumber: string;
shippingAddress: ShippingAddress;
status: null | string;
total: null | number;
updatedAt: string;
}
export interface OrderCreatePayload {
lineItems?: LineItemNestedPayload[];
orderNumber: string;
shippingAddress?: ShippingAddressNestedPayload;
}
export interface OrderCreateSuccessResponseBody {
meta?: Record<string, unknown>;
order: Order;
}
export interface OrderIndexSuccessResponseBody {
meta?: Record<string, unknown>;
orders: Order[];
pagination: OffsetPagination;
}
export interface OrderPage {
number?: number;
size?: number;
}
export interface OrderShowSuccessResponseBody {
meta?: Record<string, unknown>;
order: Order;
}
export interface OrderUpdatePayload {
lineItems?: LineItemNestedPayload[];
orderNumber?: string;
shippingAddress?: ShippingAddressNestedPayload;
}
export interface OrderUpdateSuccessResponseBody {
meta?: Record<string, unknown>;
order: Order;
}
export interface OrdersCreateRequest {
body: OrdersCreateRequestBody;
}
export interface OrdersCreateRequestBody {
order: OrderCreatePayload;
}
export interface OrdersCreateResponse {
body: OrdersCreateResponseBody;
}
export type OrdersCreateResponseBody = ErrorResponseBody | OrderCreateSuccessResponseBody;
export type OrdersDestroyResponse = never;
export interface OrdersIndexRequest {
query: OrdersIndexRequestQuery;
}
export interface OrdersIndexRequestQuery {
page?: OrderPage;
}
export interface OrdersIndexResponse {
body: OrdersIndexResponseBody;
}
export type OrdersIndexResponseBody = ErrorResponseBody | OrderIndexSuccessResponseBody;
export interface OrdersShowResponse {
body: OrdersShowResponseBody;
}
export type OrdersShowResponseBody = ErrorResponseBody | OrderShowSuccessResponseBody;
export interface OrdersUpdateRequest {
body: OrdersUpdateRequestBody;
}
export interface OrdersUpdateRequestBody {
order: OrderUpdatePayload;
}
export interface OrdersUpdateResponse {
body: OrdersUpdateResponseBody;
}
export type OrdersUpdateResponseBody = ErrorResponseBody | OrderUpdateSuccessResponseBody;
export interface ShippingAddress {
city: string;
country: string;
id: string;
postalCode: string;
street: string;
}
export interface ShippingAddressNestedCreatePayload {
OP?: 'create';
city: string;
country: string;
postalCode: string;
street: string;
}
export interface ShippingAddressNestedDeletePayload {
OP?: 'delete';
id: string;
}
export type ShippingAddressNestedPayload = ShippingAddressNestedCreatePayload | ShippingAddressNestedUpdatePayload | ShippingAddressNestedDeletePayload;
export interface ShippingAddressNestedUpdatePayload {
OP?: 'update';
city?: string;
country?: string;
id?: string;
postalCode?: string;
street?: string;
}OpenAPI
yml
---
openapi: 3.1.0
info:
title: "/clever_rabbit"
version: 1.0.0
paths:
"/orders":
get:
operationId: ordersIndex
parameters:
- in: query
name: page
required: false
schema:
"$ref": "#/components/schemas/orderPage"
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/orderIndexSuccessResponseBody"
description: Successful response
post:
operationId: ordersCreate
requestBody:
content:
application/json:
schema:
properties:
order:
"$ref": "#/components/schemas/orderCreatePayload"
type: object
required:
- order
required: true
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/orderCreateSuccessResponseBody"
description: Successful response
'422':
description: Unprocessable Entity
content:
application/json:
schema:
"$ref": "#/components/schemas/errorResponseBody"
"/orders/{id}":
get:
operationId: ordersShow
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/orderShowSuccessResponseBody"
description: Successful response
patch:
operationId: ordersUpdate
parameters:
- in: path
name: id
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
order:
"$ref": "#/components/schemas/orderUpdatePayload"
type: object
required:
- order
required: true
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/orderUpdateSuccessResponseBody"
description: Successful response
'422':
description: Unprocessable Entity
content:
application/json:
schema:
"$ref": "#/components/schemas/errorResponseBody"
delete:
operationId: ordersDestroy
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'204':
description: No content
components:
schemas:
error:
properties:
issues:
items:
"$ref": "#/components/schemas/issue"
type: array
layer:
enum:
- http
- contract
- domain
type: string
type: object
required:
- issues
- layer
errorResponseBody:
"$ref": "#/components/schemas/error"
issue:
properties:
code:
type: string
detail:
type: string
meta:
properties: {}
type: object
path:
items:
type: string
type: array
pointer:
type: string
type: object
required:
- code
- detail
- meta
- path
- pointer
lineItem:
properties:
id:
type: string
productName:
type: string
quantity:
type:
- integer
- 'null'
unitPrice:
type:
- number
- 'null'
type: object
required:
- id
- productName
- quantity
- unitPrice
lineItemNestedCreatePayload:
properties:
OP:
const: create
type: string
productName:
type: string
quantity:
type:
- integer
- 'null'
unitPrice:
type:
- number
- 'null'
type: object
required:
- productName
lineItemNestedDeletePayload:
properties:
OP:
const: delete
type: string
id:
type: string
type: object
required:
- id
lineItemNestedPayload:
oneOf:
- "$ref": "#/components/schemas/lineItemNestedCreatePayload"
- "$ref": "#/components/schemas/lineItemNestedUpdatePayload"
- "$ref": "#/components/schemas/lineItemNestedDeletePayload"
discriminator:
mapping:
create: "#/components/schemas/lineItemNestedCreatePayload"
update: "#/components/schemas/lineItemNestedUpdatePayload"
delete: "#/components/schemas/lineItemNestedDeletePayload"
propertyName: OP
lineItemNestedUpdatePayload:
properties:
OP:
const: update
type: string
id:
type: string
productName:
type: string
quantity:
type:
- integer
- 'null'
unitPrice:
type:
- number
- 'null'
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
- total
order:
properties:
createdAt:
type: string
format: date-time
id:
type: string
lineItems:
items:
"$ref": "#/components/schemas/lineItem"
type: array
orderNumber:
type: string
shippingAddress:
"$ref": "#/components/schemas/shippingAddress"
status:
type:
- string
- 'null'
total:
type:
- number
- 'null'
updatedAt:
type: string
format: date-time
type: object
required:
- createdAt
- id
- lineItems
- orderNumber
- shippingAddress
- status
- total
- updatedAt
orderCreatePayload:
properties:
lineItems:
items:
"$ref": "#/components/schemas/lineItemNestedPayload"
type: array
orderNumber:
type: string
shippingAddress:
"$ref": "#/components/schemas/shippingAddressNestedPayload"
type: object
required:
- orderNumber
orderCreateSuccessResponseBody:
properties:
meta:
properties: {}
type: object
order:
"$ref": "#/components/schemas/order"
type: object
required:
- order
orderIndexSuccessResponseBody:
properties:
pagination:
"$ref": "#/components/schemas/offsetPagination"
meta:
properties: {}
type: object
orders:
items:
"$ref": "#/components/schemas/order"
type: array
type: object
required:
- pagination
- orders
orderPage:
properties:
number:
type: integer
minimum: 1
size:
type: integer
minimum: 1
maximum: 100
type: object
orderShowSuccessResponseBody:
properties:
meta:
properties: {}
type: object
order:
"$ref": "#/components/schemas/order"
type: object
required:
- order
orderUpdatePayload:
properties:
lineItems:
items:
"$ref": "#/components/schemas/lineItemNestedPayload"
type: array
orderNumber:
type: string
shippingAddress:
"$ref": "#/components/schemas/shippingAddressNestedPayload"
type: object
orderUpdateSuccessResponseBody:
properties:
meta:
properties: {}
type: object
order:
"$ref": "#/components/schemas/order"
type: object
required:
- order
shippingAddress:
properties:
city:
type: string
country:
type: string
id:
type: string
postalCode:
type: string
street:
type: string
type: object
required:
- city
- country
- id
- postalCode
- street
shippingAddressNestedCreatePayload:
properties:
OP:
const: create
type: string
city:
type: string
country:
type: string
postalCode:
type: string
street:
type: string
type: object
required:
- city
- country
- postalCode
- street
shippingAddressNestedDeletePayload:
properties:
OP:
const: delete
type: string
id:
type: string
type: object
required:
- id
shippingAddressNestedPayload:
oneOf:
- "$ref": "#/components/schemas/shippingAddressNestedCreatePayload"
- "$ref": "#/components/schemas/shippingAddressNestedUpdatePayload"
- "$ref": "#/components/schemas/shippingAddressNestedDeletePayload"
discriminator:
mapping:
create: "#/components/schemas/shippingAddressNestedCreatePayload"
update: "#/components/schemas/shippingAddressNestedUpdatePayload"
delete: "#/components/schemas/shippingAddressNestedDeletePayload"
propertyName: OP
shippingAddressNestedUpdatePayload:
properties:
OP:
const: update
type: string
city:
type: string
country:
type: string
id:
type: string
postalCode:
type: string
street:
type: string
type: object