Type Imports
Share type definitions between contracts with import
API Definition
config/apis/calm_turtle.rb
rb
# frozen_string_literal: true
Apiwork::API.define '/calm_turtle' do
key_format :camel
export :openapi
export :typescript
export :zod
resources :customers
resources :orders
endModels
app/models/calm_turtle/customer.rb
rb
# frozen_string_literal: true
module CalmTurtle
class Customer < ApplicationRecord
has_many :orders, dependent: :destroy
validates :name, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| billing_city | string | ✓ | |
| billing_country | string | ✓ | |
| billing_street | string | ✓ | |
| created_at | datetime | ||
| name | string | ||
| updated_at | datetime |
app/models/calm_turtle/order.rb
rb
# frozen_string_literal: true
module CalmTurtle
class Order < ApplicationRecord
belongs_to :customer
validates :order_number, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| created_at | datetime | ||
| customer_id | string | ||
| order_number | string | ||
| shipping_city | string | ✓ | |
| shipping_country | string | ✓ | |
| shipping_street | string | ✓ | |
| updated_at | datetime |
Representations
app/representations/calm_turtle/customer_representation.rb
rb
# frozen_string_literal: true
module CalmTurtle
class CustomerRepresentation < Apiwork::Representation::Base
attribute :id
attribute :name, filterable: true, writable: true
attribute :billing_street, writable: true
attribute :billing_city, writable: true
attribute :billing_country, writable: true
attribute :created_at
attribute :updated_at
end
endapp/representations/calm_turtle/order_representation.rb
rb
# frozen_string_literal: true
module CalmTurtle
class OrderRepresentation < Apiwork::Representation::Base
attribute :id
attribute :order_number, filterable: true, writable: true
attribute :customer_id, writable: true
attribute :shipping_street, writable: true
attribute :shipping_city, writable: true
attribute :shipping_country, writable: true
attribute :created_at
attribute :updated_at
end
endContracts
app/contracts/calm_turtle/customer_contract.rb
rb
# frozen_string_literal: true
module CalmTurtle
class CustomerContract < Apiwork::Contract::Base
representation CustomerRepresentation
object :address do
string :street
string :city
string :country
end
end
endapp/contracts/calm_turtle/order_contract.rb
rb
# frozen_string_literal: true
module CalmTurtle
class OrderContract < Apiwork::Contract::Base
representation OrderRepresentation
import CustomerContract, as: :customer
end
endControllers
app/controllers/calm_turtle/customers_controller.rb
rb
# frozen_string_literal: true
module CalmTurtle
class CustomersController < ApplicationController
before_action :set_customer, only: %i[show update destroy]
def index
customers = Customer.all
expose customers
end
def show
expose customer
end
def create
customer = Customer.create(contract.body[:customer])
expose customer
end
def update
customer.update(contract.body[:customer])
expose customer
end
def destroy
customer.destroy
expose customer
end
private
attr_reader :customer
def set_customer
@customer = Customer.find(params[:id])
end
end
endapp/controllers/calm_turtle/orders_controller.rb
rb
# frozen_string_literal: true
module CalmTurtle
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
Create customer
Request
http
POST /calm_turtle/customers
Content-Type: application/json
{
"customer": {
"name": "Acme Corp",
"billingStreet": "123 Main St",
"billingCity": "Springfield",
"billingCountry": "US"
}
}Response 201
json
{
"customer": {
"id": "75753994-5ee6-5196-ace1-7c3b6c63ed95",
"name": "Acme Corp",
"billingStreet": "123 Main St",
"billingCity": "Springfield",
"billingCountry": "US",
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
}
}Create order
Request
http
POST /calm_turtle/orders
Content-Type: application/json
{
"order": {
"orderNumber": "ORD-001",
"customerId": "75753994-5ee6-5196-ace1-7c3b6c63ed95",
"shippingStreet": "456 Oak Ave",
"shippingCity": "Shelbyville",
"shippingCountry": "US"
}
}Response 201
json
{
"order": {
"id": "f951f663-b887-5470-8c0c-03e090cd26eb",
"orderNumber": "ORD-001",
"customerId": "75753994-5ee6-5196-ace1-7c3b6c63ed95",
"shippingStreet": "456 Oak Ave",
"shippingCity": "Shelbyville",
"shippingCountry": "US",
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
}
}List orders
Request
http
GET /calm_turtle/ordersResponse 200
json
{
"orders": [
{
"id": "f951f663-b887-5470-8c0c-03e090cd26eb",
"orderNumber": "ORD-001",
"customerId": "75753994-5ee6-5196-ace1-7c3b6c63ed95",
"shippingStreet": "456 Oak Ave",
"shippingCity": "Shelbyville",
"shippingCountry": "US",
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
},
{
"id": "2e6425b6-4cdb-5ca7-9764-8bd9171ba992",
"orderNumber": "ORD-002",
"customerId": "75753994-5ee6-5196-ace1-7c3b6c63ed95",
"shippingStreet": "789 Elm Blvd",
"shippingCity": "Capital City",
"shippingCountry": "US",
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
}
],
"pagination": {
"items": 2,
"total": 1,
"current": 1,
"next": null,
"prev": null
}
}Generated Output
Introspection
json
{
"base_path": "/calm_turtle",
"enums": {
"layer": {
"deprecated": false,
"description": null,
"example": null,
"values": [
"http",
"contract",
"domain"
]
}
},
"error_codes": {
"unprocessable_entity": {
"description": "Unprocessable Entity",
"status": 422
}
},
"info": null,
"resources": {
"customers": {
"actions": {
"index": {
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/customers",
"raises": [],
"request": {
"body": {},
"query": {
"filter": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "customer_filter"
},
{
"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": "customer_filter"
},
"shape": {}
}
]
},
"page": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "customer_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": "customer_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": "/customers/: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": "customer_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": "/customers",
"raises": [
"unprocessable_entity"
],
"request": {
"body": {
"customer": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "customer_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": "customer_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": "/customers/:id",
"raises": [
"unprocessable_entity"
],
"request": {
"body": {
"customer": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "customer_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": "customer_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": "/customers/: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": "customers",
"parent_identifiers": [],
"path": "customers",
"resources": {}
},
"orders": {
"actions": {
"index": {
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/orders",
"raises": [],
"request": {
"body": {},
"query": {
"filter": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "order_filter"
},
{
"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_filter"
},
"shape": {}
}
]
},
"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": {
"customer": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"billing_city": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"billing_country": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"billing_street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"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
},
"name": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"updated_at": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "datetime"
}
},
"type": "object",
"variants": []
},
"customer_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
},
"street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"customer_create_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"billing_city": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"billing_country": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"billing_street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"name": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"customer_create_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"customer": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "customer"
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
}
},
"type": "object",
"variants": []
},
"customer_filter": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"AND": {
"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": "customer_filter"
},
"shape": {}
},
"NOT": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "customer_filter"
},
"OR": {
"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": "customer_filter"
},
"shape": {}
},
"name": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "string_filter"
}
]
}
},
"type": "object",
"variants": []
},
"customer_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"
},
"customers": {
"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": "customer"
},
"shape": {}
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
}
},
"type": "object",
"variants": []
},
"customer_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": []
},
"customer_show_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"customer": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "customer"
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
}
},
"type": "object",
"variants": []
},
"customer_update_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"billing_city": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"billing_country": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"billing_street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"name": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"customer_update_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"customer": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "customer"
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
}
},
"type": "object",
"variants": []
},
"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": []
},
"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"
},
"customer_id": {
"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
},
"order_number": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_city": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_country": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": false,
"type": "string",
"format": null,
"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": {
"customer_id": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"order_number": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_city": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_country": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"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_filter": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"AND": {
"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": "order_filter"
},
"shape": {}
},
"NOT": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "order_filter"
},
"OR": {
"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": "order_filter"
},
"shape": {}
},
"order_number": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "string_filter"
}
]
}
},
"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": {
"customer_id": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"order_number": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_city": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_country": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shipping_street": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"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": []
},
"string_filter": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"contains": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"ends_with": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"eq": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"in": {
"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": "string",
"format": null,
"max": null,
"min": null
},
"shape": {}
},
"starts_with": {
"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 Customer {
billingCity: null | string;
billingCountry: null | string;
billingStreet: null | string;
createdAt: string;
id: string;
name: string;
updatedAt: string;
}
export interface CustomerCreatePayload {
billingCity?: null | string;
billingCountry?: null | string;
billingStreet?: null | string;
name: string;
}
export interface CustomerCreateSuccessResponseBody {
customer: Customer;
meta?: Record<string, unknown>;
}
export interface CustomerFilter {
AND?: CustomerFilter[];
NOT?: CustomerFilter;
OR?: CustomerFilter[];
name?: StringFilter | string;
}
export interface CustomerIndexSuccessResponseBody {
customers: Customer[];
meta?: Record<string, unknown>;
pagination: OffsetPagination;
}
export interface CustomerPage {
number?: number;
size?: number;
}
export interface CustomerShowSuccessResponseBody {
customer: Customer;
meta?: Record<string, unknown>;
}
export interface CustomerUpdatePayload {
billingCity?: null | string;
billingCountry?: null | string;
billingStreet?: null | string;
name?: string;
}
export interface CustomerUpdateSuccessResponseBody {
customer: Customer;
meta?: Record<string, unknown>;
}
export interface CustomersCreateRequest {
body: CustomersCreateRequestBody;
}
export interface CustomersCreateRequestBody {
customer: CustomerCreatePayload;
}
export interface CustomersCreateResponse {
body: CustomersCreateResponseBody;
}
export type CustomersCreateResponseBody = CustomerCreateSuccessResponseBody | ErrorResponseBody;
export type CustomersDestroyResponse = never;
export interface CustomersIndexRequest {
query: CustomersIndexRequestQuery;
}
export interface CustomersIndexRequestQuery {
filter?: CustomerFilter | CustomerFilter[];
page?: CustomerPage;
}
export interface CustomersIndexResponse {
body: CustomersIndexResponseBody;
}
export type CustomersIndexResponseBody = CustomerIndexSuccessResponseBody | ErrorResponseBody;
export interface CustomersShowResponse {
body: CustomersShowResponseBody;
}
export type CustomersShowResponseBody = CustomerShowSuccessResponseBody | ErrorResponseBody;
export interface CustomersUpdateRequest {
body: CustomersUpdateRequestBody;
}
export interface CustomersUpdateRequestBody {
customer: CustomerUpdatePayload;
}
export interface CustomersUpdateResponse {
body: CustomersUpdateResponseBody;
}
export type CustomersUpdateResponseBody = CustomerUpdateSuccessResponseBody | ErrorResponseBody;
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 OffsetPagination {
current: number;
items: number;
next?: null | number;
prev?: null | number;
total: number;
}
export interface Order {
createdAt: string;
customerId: string;
id: string;
orderNumber: string;
shippingCity: null | string;
shippingCountry: null | string;
shippingStreet: null | string;
updatedAt: string;
}
export interface OrderCreatePayload {
customerId: string;
orderNumber: string;
shippingCity?: null | string;
shippingCountry?: null | string;
shippingStreet?: null | string;
}
export interface OrderCreateSuccessResponseBody {
meta?: Record<string, unknown>;
order: Order;
}
export interface OrderFilter {
AND?: OrderFilter[];
NOT?: OrderFilter;
OR?: OrderFilter[];
orderNumber?: StringFilter | string;
}
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 {
customerId?: string;
orderNumber?: string;
shippingCity?: null | string;
shippingCountry?: null | string;
shippingStreet?: null | string;
}
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 {
filter?: OrderFilter | OrderFilter[];
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 StringFilter {
contains?: string;
endsWith?: string;
eq?: string;
in?: string[];
startsWith?: string;
}Zod
ts
import { z } from 'zod';
export const LayerSchema = z.enum(['contract', 'domain', 'http']);
export const CustomerFilterSchema: z.ZodType<CustomerFilter> = z.lazy(() => z.object({
AND: z.array(CustomerFilterSchema).optional(),
NOT: CustomerFilterSchema.optional(),
OR: z.array(CustomerFilterSchema).optional(),
name: z.union([z.string(), StringFilterSchema]).optional()
}));
export const OrderFilterSchema: z.ZodType<OrderFilter> = z.lazy(() => z.object({
AND: z.array(OrderFilterSchema).optional(),
NOT: OrderFilterSchema.optional(),
OR: z.array(OrderFilterSchema).optional(),
orderNumber: z.union([z.string(), StringFilterSchema]).optional()
}));
export const CustomerSchema = z.object({
billingCity: z.string().nullable(),
billingCountry: z.string().nullable(),
billingStreet: z.string().nullable(),
createdAt: z.iso.datetime(),
id: z.string(),
name: z.string(),
updatedAt: z.iso.datetime()
});
export const CustomerCreatePayloadSchema = z.object({
billingCity: z.string().nullable().optional(),
billingCountry: z.string().nullable().optional(),
billingStreet: z.string().nullable().optional(),
name: z.string()
});
export const CustomerPageSchema = z.object({
number: z.number().int().min(1).optional(),
size: z.number().int().min(1).max(100).optional()
});
export const CustomerUpdatePayloadSchema = z.object({
billingCity: z.string().nullable().optional(),
billingCountry: z.string().nullable().optional(),
billingStreet: z.string().nullable().optional(),
name: z.string().optional()
});
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 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 OrderSchema = z.object({
createdAt: z.iso.datetime(),
customerId: z.string(),
id: z.string(),
orderNumber: z.string(),
shippingCity: z.string().nullable(),
shippingCountry: z.string().nullable(),
shippingStreet: z.string().nullable(),
updatedAt: z.iso.datetime()
});
export const OrderCreatePayloadSchema = z.object({
customerId: z.string(),
orderNumber: z.string(),
shippingCity: z.string().nullable().optional(),
shippingCountry: z.string().nullable().optional(),
shippingStreet: z.string().nullable().optional()
});
export const OrderPageSchema = z.object({
number: z.number().int().min(1).optional(),
size: z.number().int().min(1).max(100).optional()
});
export const OrderUpdatePayloadSchema = z.object({
customerId: z.string().optional(),
orderNumber: z.string().optional(),
shippingCity: z.string().nullable().optional(),
shippingCountry: z.string().nullable().optional(),
shippingStreet: z.string().nullable().optional()
});
export const StringFilterSchema = z.object({
contains: z.string().optional(),
endsWith: z.string().optional(),
eq: z.string().optional(),
in: z.array(z.string()).optional(),
startsWith: z.string().optional()
});
export const CustomerCreateSuccessResponseBodySchema = z.object({
customer: CustomerSchema,
meta: z.record(z.string(), z.unknown()).optional()
});
export const CustomerIndexSuccessResponseBodySchema = z.object({
customers: z.array(CustomerSchema),
meta: z.record(z.string(), z.unknown()).optional(),
pagination: OffsetPaginationSchema
});
export const CustomerShowSuccessResponseBodySchema = z.object({
customer: CustomerSchema,
meta: z.record(z.string(), z.unknown()).optional()
});
export const CustomerUpdateSuccessResponseBodySchema = z.object({
customer: CustomerSchema,
meta: z.record(z.string(), z.unknown()).optional()
});
export const ErrorSchema = z.object({
issues: z.array(IssueSchema),
layer: LayerSchema
});
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 OrderUpdateSuccessResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
order: OrderSchema
});
export const ErrorResponseBodySchema = ErrorSchema;
export const CustomersIndexRequestQuerySchema = z.object({
filter: z.union([CustomerFilterSchema, z.array(CustomerFilterSchema)]).optional(),
page: CustomerPageSchema.optional()
});
export const CustomersIndexRequestSchema = z.object({
query: CustomersIndexRequestQuerySchema
});
export const CustomersIndexResponseBodySchema = z.union([CustomerIndexSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const CustomersIndexResponseSchema = z.object({
body: CustomersIndexResponseBodySchema
});
export const CustomersShowResponseBodySchema = z.union([CustomerShowSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const CustomersShowResponseSchema = z.object({
body: CustomersShowResponseBodySchema
});
export const CustomersCreateRequestBodySchema = z.object({
customer: CustomerCreatePayloadSchema
});
export const CustomersCreateRequestSchema = z.object({
body: CustomersCreateRequestBodySchema
});
export const CustomersCreateResponseBodySchema = z.union([CustomerCreateSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const CustomersCreateResponseSchema = z.object({
body: CustomersCreateResponseBodySchema
});
export const CustomersUpdateRequestBodySchema = z.object({
customer: CustomerUpdatePayloadSchema
});
export const CustomersUpdateRequestSchema = z.object({
body: CustomersUpdateRequestBodySchema
});
export const CustomersUpdateResponseBodySchema = z.union([CustomerUpdateSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const CustomersUpdateResponseSchema = z.object({
body: CustomersUpdateResponseBodySchema
});
export const CustomersDestroyResponseSchema = z.never();
export const OrdersIndexRequestQuerySchema = z.object({
filter: z.union([OrderFilterSchema, z.array(OrderFilterSchema)]).optional(),
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 Customer {
billingCity: null | string;
billingCountry: null | string;
billingStreet: null | string;
createdAt: string;
id: string;
name: string;
updatedAt: string;
}
export interface CustomerCreatePayload {
billingCity?: null | string;
billingCountry?: null | string;
billingStreet?: null | string;
name: string;
}
export interface CustomerCreateSuccessResponseBody {
customer: Customer;
meta?: Record<string, unknown>;
}
export interface CustomerFilter {
AND?: CustomerFilter[];
NOT?: CustomerFilter;
OR?: CustomerFilter[];
name?: StringFilter | string;
}
export interface CustomerIndexSuccessResponseBody {
customers: Customer[];
meta?: Record<string, unknown>;
pagination: OffsetPagination;
}
export interface CustomerPage {
number?: number;
size?: number;
}
export interface CustomerShowSuccessResponseBody {
customer: Customer;
meta?: Record<string, unknown>;
}
export interface CustomerUpdatePayload {
billingCity?: null | string;
billingCountry?: null | string;
billingStreet?: null | string;
name?: string;
}
export interface CustomerUpdateSuccessResponseBody {
customer: Customer;
meta?: Record<string, unknown>;
}
export interface CustomersCreateRequest {
body: CustomersCreateRequestBody;
}
export interface CustomersCreateRequestBody {
customer: CustomerCreatePayload;
}
export interface CustomersCreateResponse {
body: CustomersCreateResponseBody;
}
export type CustomersCreateResponseBody = CustomerCreateSuccessResponseBody | ErrorResponseBody;
export type CustomersDestroyResponse = never;
export interface CustomersIndexRequest {
query: CustomersIndexRequestQuery;
}
export interface CustomersIndexRequestQuery {
filter?: CustomerFilter | CustomerFilter[];
page?: CustomerPage;
}
export interface CustomersIndexResponse {
body: CustomersIndexResponseBody;
}
export type CustomersIndexResponseBody = CustomerIndexSuccessResponseBody | ErrorResponseBody;
export interface CustomersShowResponse {
body: CustomersShowResponseBody;
}
export type CustomersShowResponseBody = CustomerShowSuccessResponseBody | ErrorResponseBody;
export interface CustomersUpdateRequest {
body: CustomersUpdateRequestBody;
}
export interface CustomersUpdateRequestBody {
customer: CustomerUpdatePayload;
}
export interface CustomersUpdateResponse {
body: CustomersUpdateResponseBody;
}
export type CustomersUpdateResponseBody = CustomerUpdateSuccessResponseBody | ErrorResponseBody;
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 OffsetPagination {
current: number;
items: number;
next?: null | number;
prev?: null | number;
total: number;
}
export interface Order {
createdAt: string;
customerId: string;
id: string;
orderNumber: string;
shippingCity: null | string;
shippingCountry: null | string;
shippingStreet: null | string;
updatedAt: string;
}
export interface OrderCreatePayload {
customerId: string;
orderNumber: string;
shippingCity?: null | string;
shippingCountry?: null | string;
shippingStreet?: null | string;
}
export interface OrderCreateSuccessResponseBody {
meta?: Record<string, unknown>;
order: Order;
}
export interface OrderFilter {
AND?: OrderFilter[];
NOT?: OrderFilter;
OR?: OrderFilter[];
orderNumber?: StringFilter | string;
}
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 {
customerId?: string;
orderNumber?: string;
shippingCity?: null | string;
shippingCountry?: null | string;
shippingStreet?: null | string;
}
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 {
filter?: OrderFilter | OrderFilter[];
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 StringFilter {
contains?: string;
endsWith?: string;
eq?: string;
in?: string[];
startsWith?: string;
}OpenAPI
yml
---
openapi: 3.1.0
info:
title: "/calm_turtle"
version: 1.0.0
paths:
"/customers":
get:
operationId: customersIndex
parameters:
- in: query
name: filter
required: false
schema:
oneOf:
- "$ref": "#/components/schemas/customerFilter"
- items:
"$ref": "#/components/schemas/customerFilter"
type: array
- in: query
name: page
required: false
schema:
"$ref": "#/components/schemas/customerPage"
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/customerIndexSuccessResponseBody"
description: Successful response
post:
operationId: customersCreate
requestBody:
content:
application/json:
schema:
properties:
customer:
"$ref": "#/components/schemas/customerCreatePayload"
type: object
required:
- customer
required: true
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/customerCreateSuccessResponseBody"
description: Successful response
'422':
description: Unprocessable Entity
content:
application/json:
schema:
"$ref": "#/components/schemas/errorResponseBody"
"/customers/{id}":
get:
operationId: customersShow
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/customerShowSuccessResponseBody"
description: Successful response
patch:
operationId: customersUpdate
parameters:
- in: path
name: id
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
customer:
"$ref": "#/components/schemas/customerUpdatePayload"
type: object
required:
- customer
required: true
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/customerUpdateSuccessResponseBody"
description: Successful response
'422':
description: Unprocessable Entity
content:
application/json:
schema:
"$ref": "#/components/schemas/errorResponseBody"
delete:
operationId: customersDestroy
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'204':
description: No content
"/orders":
get:
operationId: ordersIndex
parameters:
- in: query
name: filter
required: false
schema:
oneOf:
- "$ref": "#/components/schemas/orderFilter"
- items:
"$ref": "#/components/schemas/orderFilter"
type: array
- 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:
customer:
properties:
billingCity:
type:
- string
- 'null'
billingCountry:
type:
- string
- 'null'
billingStreet:
type:
- string
- 'null'
createdAt:
type: string
format: date-time
id:
type: string
name:
type: string
updatedAt:
type: string
format: date-time
type: object
required:
- billingCity
- billingCountry
- billingStreet
- createdAt
- id
- name
- updatedAt
customerCreatePayload:
properties:
billingCity:
type:
- string
- 'null'
billingCountry:
type:
- string
- 'null'
billingStreet:
type:
- string
- 'null'
name:
type: string
type: object
required:
- name
customerCreateSuccessResponseBody:
properties:
customer:
"$ref": "#/components/schemas/customer"
meta:
properties: {}
type: object
type: object
required:
- customer
customerFilter:
properties:
AND:
items:
"$ref": "#/components/schemas/customerFilter"
type: array
NOT:
"$ref": "#/components/schemas/customerFilter"
OR:
items:
"$ref": "#/components/schemas/customerFilter"
type: array
name:
oneOf:
- type: string
- "$ref": "#/components/schemas/stringFilter"
type: object
customerIndexSuccessResponseBody:
properties:
pagination:
"$ref": "#/components/schemas/offsetPagination"
customers:
items:
"$ref": "#/components/schemas/customer"
type: array
meta:
properties: {}
type: object
type: object
required:
- pagination
- customers
customerPage:
properties:
number:
type: integer
minimum: 1
size:
type: integer
minimum: 1
maximum: 100
type: object
customerShowSuccessResponseBody:
properties:
customer:
"$ref": "#/components/schemas/customer"
meta:
properties: {}
type: object
type: object
required:
- customer
customerUpdatePayload:
properties:
billingCity:
type:
- string
- 'null'
billingCountry:
type:
- string
- 'null'
billingStreet:
type:
- string
- 'null'
name:
type: string
type: object
customerUpdateSuccessResponseBody:
properties:
customer:
"$ref": "#/components/schemas/customer"
meta:
properties: {}
type: object
type: object
required:
- customer
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
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
customerId:
type: string
id:
type: string
orderNumber:
type: string
shippingCity:
type:
- string
- 'null'
shippingCountry:
type:
- string
- 'null'
shippingStreet:
type:
- string
- 'null'
updatedAt:
type: string
format: date-time
type: object
required:
- createdAt
- customerId
- id
- orderNumber
- shippingCity
- shippingCountry
- shippingStreet
- updatedAt
orderCreatePayload:
properties:
customerId:
type: string
orderNumber:
type: string
shippingCity:
type:
- string
- 'null'
shippingCountry:
type:
- string
- 'null'
shippingStreet:
type:
- string
- 'null'
type: object
required:
- customerId
- orderNumber
orderCreateSuccessResponseBody:
properties:
meta:
properties: {}
type: object
order:
"$ref": "#/components/schemas/order"
type: object
required:
- order
orderFilter:
properties:
AND:
items:
"$ref": "#/components/schemas/orderFilter"
type: array
NOT:
"$ref": "#/components/schemas/orderFilter"
OR:
items:
"$ref": "#/components/schemas/orderFilter"
type: array
orderNumber:
oneOf:
- type: string
- "$ref": "#/components/schemas/stringFilter"
type: object
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:
customerId:
type: string
orderNumber:
type: string
shippingCity:
type:
- string
- 'null'
shippingCountry:
type:
- string
- 'null'
shippingStreet:
type:
- string
- 'null'
type: object
orderUpdateSuccessResponseBody:
properties:
meta:
properties: {}
type: object
order:
"$ref": "#/components/schemas/order"
type: object
required:
- order
stringFilter:
properties:
contains:
type: string
endsWith:
type: string
eq:
type: string
in:
items:
type: string
type: array
startsWith:
type: string
type: object