Single Table Inheritance
Single Table Inheritance with automatic variant serialization and TypeScript union types
API Definition
config/apis/mighty_wolf.rb
rb
# frozen_string_literal: true
Apiwork::API.define '/mighty_wolf' do
key_format :camel
export :openapi
export :apiwork
resources :vehicles
endModels
app/models/mighty_wolf/vehicle.rb
rb
# frozen_string_literal: true
module MightyWolf
class Vehicle < ApplicationRecord
validates :brand, :model, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| brand | string | ||
| color | string | ✓ | |
| created_at | datetime | ||
| doors | integer | ✓ | |
| engine_cc | integer | ✓ | |
| model | string | ||
| payload_capacity | decimal | ✓ | |
| type | string | ||
| updated_at | datetime | ||
| year | integer | ✓ |
app/models/mighty_wolf/car.rb
rb
# frozen_string_literal: true
module MightyWolf
class Car < Vehicle
end
endapp/models/mighty_wolf/truck.rb
rb
# frozen_string_literal: true
module MightyWolf
class Truck < Vehicle
end
endapp/models/mighty_wolf/motorcycle.rb
rb
# frozen_string_literal: true
module MightyWolf
class Motorcycle < Vehicle
end
endRepresentations
app/representations/mighty_wolf/vehicle_representation.rb
rb
# frozen_string_literal: true
module MightyWolf
class VehicleRepresentation < Apiwork::Representation::Base
attribute :id
attribute :type, filterable: true
attribute :brand, filterable: true, writable: true
attribute :model, filterable: true, writable: true
attribute :year, filterable: true, sortable: true, writable: true
attribute :color, writable: true
attribute :created_at
attribute :updated_at
end
endapp/representations/mighty_wolf/car_representation.rb
rb
# frozen_string_literal: true
module MightyWolf
class CarRepresentation < VehicleRepresentation
type_name :car
attribute :doors, writable: true
end
endapp/representations/mighty_wolf/truck_representation.rb
rb
# frozen_string_literal: true
module MightyWolf
class TruckRepresentation < VehicleRepresentation
type_name :truck
attribute :payload_capacity, writable: true
end
endapp/representations/mighty_wolf/motorcycle_representation.rb
rb
# frozen_string_literal: true
module MightyWolf
class MotorcycleRepresentation < VehicleRepresentation
type_name :motorcycle
attribute :engine_cc, writable: true
end
endContracts
app/contracts/mighty_wolf/vehicle_contract.rb
rb
# frozen_string_literal: true
module MightyWolf
class VehicleContract < Apiwork::Contract::Base
representation VehicleRepresentation
end
endControllers
app/controllers/mighty_wolf/vehicles_controller.rb
rb
# frozen_string_literal: true
module MightyWolf
class VehiclesController < ApplicationController
before_action :set_vehicle, only: %i[show update destroy]
def index
vehicles = Vehicle.all
expose vehicles
end
def show
expose vehicle
end
def create
vehicle = Vehicle.create(contract.body[:vehicle])
expose vehicle
end
def update
vehicle.update(contract.body[:vehicle])
expose vehicle
end
def destroy
vehicle.destroy
expose vehicle
end
private
attr_reader :vehicle
def set_vehicle
@vehicle = Vehicle.find(params[:id])
end
end
endRequest Examples
List all vehicles
Request
http
GET /mighty_wolf/vehiclesResponse 200
json
{
"vehicles": [
{
"type": "car",
"id": "7900de74-233c-5bc9-bc0c-6679f7a345a5",
"brand": "Volvo",
"model": "EX30",
"year": null,
"color": null,
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z",
"doors": 4
},
{
"type": "motorcycle",
"id": "7806556d-7175-57da-9ab8-a1d92437b144",
"brand": "Harley-Davidson",
"model": "Street Glide",
"year": null,
"color": null,
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z",
"engineCc": 1868
},
{
"type": "truck",
"id": "0cfa971d-c697-5cff-be68-cf775df891c1",
"brand": "Ford",
"model": "F-150",
"year": null,
"color": null,
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z",
"payloadCapacity": "5000.0"
}
],
"pagination": {
"items": 3,
"total": 1,
"current": 1,
"next": null,
"prev": null
}
}Get vehicle details
Request
http
GET /mighty_wolf/vehicles/7900de74-233c-5bc9-bc0c-6679f7a345a5Response 200
json
{
"vehicle": {
"type": "car",
"id": "7900de74-233c-5bc9-bc0c-6679f7a345a5",
"brand": "Volvo",
"model": "EX30",
"year": 2024,
"color": "red",
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z",
"doors": 4
}
}Create a car
Request
http
POST /mighty_wolf/vehicles
Content-Type: application/json
{
"vehicle": {
"type": "car",
"brand": "Volvo",
"model": "EX30",
"year": 2024,
"color": "red",
"doors": 4
}
}Response 201
json
{
"vehicle": {
"type": "car",
"id": "7900de74-233c-5bc9-bc0c-6679f7a345a5",
"brand": "Volvo",
"model": "EX30",
"year": 2024,
"color": "red",
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z",
"doors": 4
}
}Create a truck
Request
http
POST /mighty_wolf/vehicles
Content-Type: application/json
{
"vehicle": {
"type": "truck",
"brand": "Ford",
"model": "F-150",
"year": 2024,
"color": "blue",
"payloadCapacity": 5000
}
}Response 201
json
{
"vehicle": {
"type": "truck",
"id": "0cfa971d-c697-5cff-be68-cf775df891c1",
"brand": "Ford",
"model": "F-150",
"year": 2024,
"color": "blue",
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z",
"payloadCapacity": "5000.0"
}
}Filter by vehicle type
Request
http
GET /mighty_wolf/vehicles?filter[type][eq]=carResponse 200
json
{
"vehicles": [
{
"type": "car",
"id": "7900de74-233c-5bc9-bc0c-6679f7a345a5",
"brand": "Volvo",
"model": "EX30",
"year": null,
"color": null,
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z",
"doors": null
}
],
"pagination": {
"items": 1,
"total": 1,
"current": 1,
"next": null,
"prev": null
}
}Exports
OpenAPI
yml
---
openapi: 3.1.0
info:
title: "/mighty_wolf"
version: 1.0.0
paths:
"/vehicles":
get:
operationId: vehiclesIndex
parameters:
- in: query
name: filter
required: false
schema:
oneOf:
- "$ref": "#/components/schemas/vehicleFilter"
- items:
"$ref": "#/components/schemas/vehicleFilter"
type: array
- in: query
name: page
required: false
schema:
"$ref": "#/components/schemas/vehiclePage"
- in: query
name: sort
required: false
schema:
oneOf:
- "$ref": "#/components/schemas/vehicleSort"
- items:
"$ref": "#/components/schemas/vehicleSort"
type: array
responses:
'200':
content:
application/json:
schema:
properties:
meta:
properties: {}
type: object
pagination:
"$ref": "#/components/schemas/offsetPagination"
vehicles:
items:
"$ref": "#/components/schemas/vehicle"
type: array
type: object
required:
- pagination
- vehicles
description: ''
post:
operationId: vehiclesCreate
requestBody:
content:
application/json:
schema:
properties:
vehicle:
oneOf:
- "$ref": "#/components/schemas/carCreatePayload"
- "$ref": "#/components/schemas/motorcycleCreatePayload"
- "$ref": "#/components/schemas/truckCreatePayload"
discriminator:
mapping:
car: "#/components/schemas/carCreatePayload"
motorcycle: "#/components/schemas/motorcycleCreatePayload"
truck: "#/components/schemas/truckCreatePayload"
propertyName: type
type: object
required:
- vehicle
required: true
responses:
'200':
content:
application/json:
schema:
properties:
meta:
properties: {}
type: object
vehicle:
oneOf:
- "$ref": "#/components/schemas/car"
- "$ref": "#/components/schemas/motorcycle"
- "$ref": "#/components/schemas/truck"
discriminator:
mapping:
car: "#/components/schemas/car"
motorcycle: "#/components/schemas/motorcycle"
truck: "#/components/schemas/truck"
propertyName: type
type: object
required:
- vehicle
description: ''
'422':
description: Unprocessable Entity
content:
application/json:
schema:
properties:
issues:
items:
"$ref": "#/components/schemas/error"
type: array
required:
- issues
type: object
"/vehicles/{id}":
get:
operationId: vehiclesShow
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
properties:
meta:
properties: {}
type: object
vehicle:
oneOf:
- "$ref": "#/components/schemas/car"
- "$ref": "#/components/schemas/motorcycle"
- "$ref": "#/components/schemas/truck"
discriminator:
mapping:
car: "#/components/schemas/car"
motorcycle: "#/components/schemas/motorcycle"
truck: "#/components/schemas/truck"
propertyName: type
type: object
required:
- vehicle
description: ''
patch:
operationId: vehiclesUpdate
parameters:
- in: path
name: id
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
vehicle:
oneOf:
- "$ref": "#/components/schemas/carUpdatePayload"
- "$ref": "#/components/schemas/motorcycleUpdatePayload"
- "$ref": "#/components/schemas/truckUpdatePayload"
discriminator:
mapping:
car: "#/components/schemas/carUpdatePayload"
motorcycle: "#/components/schemas/motorcycleUpdatePayload"
truck: "#/components/schemas/truckUpdatePayload"
propertyName: type
type: object
required:
- vehicle
required: true
responses:
'200':
content:
application/json:
schema:
properties:
meta:
properties: {}
type: object
vehicle:
oneOf:
- "$ref": "#/components/schemas/car"
- "$ref": "#/components/schemas/motorcycle"
- "$ref": "#/components/schemas/truck"
discriminator:
mapping:
car: "#/components/schemas/car"
motorcycle: "#/components/schemas/motorcycle"
truck: "#/components/schemas/truck"
propertyName: type
type: object
required:
- vehicle
description: ''
'422':
description: Unprocessable Entity
content:
application/json:
schema:
properties:
issues:
items:
"$ref": "#/components/schemas/error"
type: array
required:
- issues
type: object
delete:
operationId: vehiclesDestroy
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'204':
description: ''
components:
schemas:
car:
properties:
brand:
type: string
color:
type:
- string
- 'null'
createdAt:
type: string
format: date-time
doors:
type:
- integer
- 'null'
id:
type: string
model:
type: string
type:
type: string
updatedAt:
type: string
format: date-time
year:
type:
- integer
- 'null'
type: object
required:
- brand
- color
- createdAt
- doors
- id
- model
- type
- updatedAt
- year
carCreatePayload:
properties:
brand:
type: string
color:
type:
- string
- 'null'
default:
doors:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
default:
model:
type: string
type:
const: car
type: string
year:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
default:
type: object
required:
- brand
- model
- type
carUpdatePayload:
properties:
brand:
type: string
color:
type:
- string
- 'null'
doors:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
model:
type: string
type:
const: car
type: string
year:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
type: object
error:
properties:
issues:
items:
"$ref": "#/components/schemas/errorIssue"
type: array
layer:
enum:
- http
- contract
- domain
type: string
type: object
required:
- issues
- layer
errorIssue:
properties:
code:
type: string
detail:
type: string
meta:
properties: {}
type: object
path:
items:
oneOf:
- type: string
- type: integer
type: array
pointer:
type: string
type: object
required:
- code
- detail
- meta
- path
- pointer
integerFilterBetween:
properties:
from:
type: integer
to:
type: integer
type: object
motorcycle:
properties:
brand:
type: string
color:
type:
- string
- 'null'
createdAt:
type: string
format: date-time
engineCc:
type:
- integer
- 'null'
id:
type: string
model:
type: string
type:
type: string
updatedAt:
type: string
format: date-time
year:
type:
- integer
- 'null'
type: object
required:
- brand
- color
- createdAt
- engineCc
- id
- model
- type
- updatedAt
- year
motorcycleCreatePayload:
properties:
brand:
type: string
color:
type:
- string
- 'null'
default:
engineCc:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
default:
model:
type: string
type:
const: motorcycle
type: string
year:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
default:
type: object
required:
- brand
- model
- type
motorcycleUpdatePayload:
properties:
brand:
type: string
color:
type:
- string
- 'null'
engineCc:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
model:
type: string
type:
const: motorcycle
type: string
year:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
type: object
nullableIntegerFilter:
properties:
between:
"$ref": "#/components/schemas/integerFilterBetween"
eq:
type: integer
gt:
type: integer
gte:
type: integer
in:
items:
type: integer
type: array
lt:
type: integer
lte:
type: integer
'null':
type: boolean
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
stringFilter:
properties:
contains:
type: string
endsWith:
type: string
eq:
type: string
in:
items:
type: string
type: array
startsWith:
type: string
type: object
truck:
properties:
brand:
type: string
color:
type:
- string
- 'null'
createdAt:
type: string
format: date-time
id:
type: string
model:
type: string
payloadCapacity:
type:
- number
- 'null'
type:
type: string
updatedAt:
type: string
format: date-time
year:
type:
- integer
- 'null'
type: object
required:
- brand
- color
- createdAt
- id
- model
- payloadCapacity
- type
- updatedAt
- year
truckCreatePayload:
properties:
brand:
type: string
color:
type:
- string
- 'null'
default:
model:
type: string
payloadCapacity:
type:
- number
- 'null'
minimum: -99999999.99
maximum: 99999999.99
default:
type:
const: truck
type: string
year:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
default:
type: object
required:
- brand
- model
- type
truckUpdatePayload:
properties:
brand:
type: string
color:
type:
- string
- 'null'
model:
type: string
payloadCapacity:
type:
- number
- 'null'
minimum: -99999999.99
maximum: 99999999.99
type:
const: truck
type: string
year:
type:
- integer
- 'null'
minimum: -2147483648
maximum: 2147483647
type: object
vehicle:
oneOf:
- "$ref": "#/components/schemas/car"
- "$ref": "#/components/schemas/motorcycle"
- "$ref": "#/components/schemas/truck"
discriminator:
mapping:
car: "#/components/schemas/car"
motorcycle: "#/components/schemas/motorcycle"
truck: "#/components/schemas/truck"
propertyName: type
vehicleFilter:
properties:
AND:
items:
"$ref": "#/components/schemas/vehicleFilter"
type: array
NOT:
"$ref": "#/components/schemas/vehicleFilter"
OR:
items:
"$ref": "#/components/schemas/vehicleFilter"
type: array
brand:
oneOf:
- type: string
- "$ref": "#/components/schemas/stringFilter"
model:
oneOf:
- type: string
- "$ref": "#/components/schemas/stringFilter"
type:
"$ref": "#/components/schemas/vehicleTypeFilter"
year:
oneOf:
- type: integer
- "$ref": "#/components/schemas/nullableIntegerFilter"
type: object
vehiclePage:
properties:
number:
type: integer
minimum: 1
size:
type: integer
minimum: 1
maximum: 100
type: object
vehicleSort:
properties:
year:
enum:
- asc
- desc
type: string
type: object
vehicleTypeFilter:
oneOf:
- enum:
- car
- motorcycle
- truck
type: string
- properties:
eq:
enum:
- car
- motorcycle
- truck
type: string
in:
items:
enum:
- car
- motorcycle
- truck
type: string
type: array
type: object
required:
- eq
- inApiwork
json
{
"base_path": "/mighty_wolf",
"enums": [
{
"deprecated": false,
"description": null,
"example": null,
"name": "error_layer",
"scope": null,
"values": [
"http",
"contract",
"domain"
]
},
{
"deprecated": false,
"description": null,
"example": null,
"name": "sort_direction",
"scope": null,
"values": [
"asc",
"desc"
]
},
{
"deprecated": false,
"description": null,
"example": null,
"name": "vehicle_type",
"scope": "vehicle",
"values": [
"car",
"motorcycle",
"truck"
]
}
],
"error_codes": [
{
"description": "Unprocessable Entity",
"name": "unprocessable_entity",
"status": 422
}
],
"fingerprint": "b3b2c2391c6d4606",
"info": null,
"locales": [],
"resources": [
{
"actions": [
{
"name": "vehicles.index",
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/vehicles",
"raises": [],
"request": {
"body": [],
"description": null,
"query": [
{
"name": "filter",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "vehicle_filter"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "vehicle_filter"
}
}
]
},
{
"name": "page",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "vehicle_page"
},
{
"name": "sort",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "vehicle_sort"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "vehicle_sort"
}
}
]
}
]
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": []
},
{
"name": "pagination",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "offset_pagination"
},
{
"name": "vehicles",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "vehicle"
}
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "vehicles.show",
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/vehicles/:id",
"raises": [],
"request": {
"body": [],
"description": null,
"query": []
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": []
},
{
"name": "vehicle",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "union",
"discriminator": "type",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "car",
"tag": "car"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "motorcycle",
"tag": "motorcycle"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "truck",
"tag": "truck"
}
]
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "vehicles.create",
"deprecated": false,
"description": null,
"method": "post",
"operation_id": null,
"path": "/vehicles",
"raises": [
"unprocessable_entity"
],
"request": {
"body": [
{
"name": "vehicle",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "union",
"discriminator": "type",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "car_create_payload",
"tag": "car"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "motorcycle_create_payload",
"tag": "motorcycle"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "truck_create_payload",
"tag": "truck"
}
]
}
],
"description": null,
"query": []
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": []
},
{
"name": "vehicle",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "union",
"discriminator": "type",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "car",
"tag": "car"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "motorcycle",
"tag": "motorcycle"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "truck",
"tag": "truck"
}
]
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "vehicles.update",
"deprecated": false,
"description": null,
"method": "patch",
"operation_id": null,
"path": "/vehicles/:id",
"raises": [
"unprocessable_entity"
],
"request": {
"body": [
{
"name": "vehicle",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "union",
"discriminator": "type",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "car_update_payload",
"tag": "car"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "motorcycle_update_payload",
"tag": "motorcycle"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "truck_update_payload",
"tag": "truck"
}
]
}
],
"description": null,
"query": []
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": []
},
{
"name": "vehicle",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "union",
"discriminator": "type",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "car",
"tag": "car"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "motorcycle",
"tag": "motorcycle"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "truck",
"tag": "truck"
}
]
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "vehicles.destroy",
"deprecated": false,
"description": null,
"method": "delete",
"operation_id": null,
"path": "/vehicles/:id",
"raises": [],
"request": {
"body": [],
"description": null,
"query": []
},
"response": {
"body": null,
"description": null,
"no_content": true
},
"summary": null,
"tags": []
}
],
"identifier": "vehicles",
"name": "vehicles",
"parent_identifiers": [],
"path": "vehicles",
"resources": [],
"scope": "vehicle"
}
],
"types": [
{
"recursive": true,
"deprecated": false,
"description": null,
"example": null,
"name": "vehicle_filter",
"scope": "vehicle",
"type": "object",
"extends": [],
"shape": [
{
"name": "AND",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "vehicle_filter"
}
},
{
"name": "NOT",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "vehicle_filter"
},
{
"name": "OR",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "vehicle_filter"
}
},
{
"name": "brand",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "string_filter"
}
]
},
{
"name": "model",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "string_filter"
}
]
},
{
"name": "type",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "vehicle_type_filter"
},
{
"name": "year",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "nullable_integer_filter"
}
]
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "car",
"scope": "car",
"type": "object",
"extends": [],
"shape": [
{
"name": "brand",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "color",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "createdAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
},
{
"name": "doors",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "id",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "model",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "type",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "updatedAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
},
{
"name": "year",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "car_create_payload",
"scope": "car",
"type": "object",
"extends": [],
"shape": [
{
"name": "brand",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "color",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "string",
"default": null,
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "doors",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"default": null,
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
},
{
"name": "model",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "type",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "literal",
"value": "car"
},
{
"name": "year",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"default": null,
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "car_update_payload",
"scope": "car",
"type": "object",
"extends": [],
"shape": [
{
"name": "brand",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "color",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "doors",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
},
{
"name": "model",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "type",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "literal",
"value": "car"
},
{
"name": "year",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "error_issue",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "code",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "detail",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "object",
"partial": false,
"shape": []
},
{
"name": "path",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
}
},
{
"name": "pointer",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "integer_filter_between",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "from",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "to",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "motorcycle",
"scope": "motorcycle",
"type": "object",
"extends": [],
"shape": [
{
"name": "brand",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "color",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "createdAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
},
{
"name": "engineCc",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "id",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "model",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "type",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "updatedAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
},
{
"name": "year",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "motorcycle_create_payload",
"scope": "motorcycle",
"type": "object",
"extends": [],
"shape": [
{
"name": "brand",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "color",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "string",
"default": null,
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "engineCc",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"default": null,
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
},
{
"name": "model",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "type",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "literal",
"value": "motorcycle"
},
{
"name": "year",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"default": null,
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "motorcycle_update_payload",
"scope": "motorcycle",
"type": "object",
"extends": [],
"shape": [
{
"name": "brand",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "color",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "engineCc",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
},
{
"name": "model",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "type",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "literal",
"value": "motorcycle"
},
{
"name": "year",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "offset_pagination",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "current",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "items",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "next",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "prev",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "total",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "string_filter",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "contains",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "endsWith",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "eq",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "in",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
}
},
{
"name": "startsWith",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "truck",
"scope": "truck",
"type": "object",
"extends": [],
"shape": [
{
"name": "brand",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "color",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "createdAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
},
{
"name": "id",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "model",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "payloadCapacity",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "decimal",
"example": null,
"max": null,
"min": null
},
{
"name": "type",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "updatedAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
},
{
"name": "year",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "truck_create_payload",
"scope": "truck",
"type": "object",
"extends": [],
"shape": [
{
"name": "brand",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "color",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "string",
"default": null,
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "model",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "payloadCapacity",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "decimal",
"default": null,
"example": null,
"max": 99999999.99,
"min": -99999999.99
},
{
"name": "type",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "literal",
"value": "truck"
},
{
"name": "year",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"default": null,
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "truck_update_payload",
"scope": "truck",
"type": "object",
"extends": [],
"shape": [
{
"name": "brand",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "color",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "model",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "payloadCapacity",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "decimal",
"example": null,
"max": 99999999.99,
"min": -99999999.99
},
{
"name": "type",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "literal",
"value": "truck"
},
{
"name": "year",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": 2147483647,
"min": -2147483648
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "vehicle_page",
"scope": "vehicle",
"type": "object",
"extends": [],
"shape": [
{
"name": "number",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": 1
},
{
"name": "size",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": 100,
"min": 1
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "vehicle_sort",
"scope": "vehicle",
"type": "object",
"extends": [],
"shape": [
{
"name": "year",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "vehicle_type_filter",
"scope": "vehicle",
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "vehicle_type"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "object",
"partial": true,
"shape": [
{
"name": "eq",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "vehicle_type"
},
{
"name": "in",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "vehicle_type"
}
}
]
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "error",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "issues",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "error_issue"
}
},
{
"name": "layer",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "error_layer"
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "nullable_integer_filter",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "between",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "integer_filter_between"
},
{
"name": "eq",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "gt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "gte",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "in",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
},
{
"name": "lt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "lte",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "null",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "boolean",
"example": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "vehicle",
"scope": "vehicle",
"type": "union",
"discriminator": "type",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "car",
"tag": "car"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "motorcycle",
"tag": "motorcycle"
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "truck",
"tag": "truck"
}
]
}
]
}Codegen
TypeScript
ts
export type ErrorLayer = 'http' | 'contract' | 'domain';
export type SortDirection = 'asc' | 'desc';
export interface ErrorIssue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string | number[];
pointer: string;
}
export interface IntegerFilterBetween {
from?: number;
to?: number;
}
export interface OffsetPagination {
current: number;
items: number;
next?: number | null;
prev?: number | null;
total: number;
}
export interface StringFilter {
contains?: string;
endsWith?: string;
eq?: string;
in?: string[];
startsWith?: string;
}
export interface Error {
issues: ErrorIssue[];
layer: ErrorLayer;
}
export interface NullableIntegerFilter {
between?: IntegerFilterBetween;
eq?: number;
gt?: number;
gte?: number;
in?: number[];
lt?: number;
lte?: number;
null?: boolean;
}ts
export interface Car {
brand: string;
color: string | null;
createdAt: string;
doors: number | null;
id: string;
model: string;
type: string;
updatedAt: string;
year: number | null;
}
export interface CarCreatePayload {
brand: string;
color?: string | null;
doors?: number | null;
model: string;
type: 'car';
year?: number | null;
}
export interface CarUpdatePayload {
brand?: string;
color?: string | null;
doors?: number | null;
model?: string;
type?: 'car';
year?: number | null;
}ts
export * from './car';
export * from './motorcycle';
export * from './truck';
export * from './vehicle';ts
export interface Motorcycle {
brand: string;
color: string | null;
createdAt: string;
engineCc: number | null;
id: string;
model: string;
type: string;
updatedAt: string;
year: number | null;
}
export interface MotorcycleCreatePayload {
brand: string;
color?: string | null;
engineCc?: number | null;
model: string;
type: 'motorcycle';
year?: number | null;
}
export interface MotorcycleUpdatePayload {
brand?: string;
color?: string | null;
engineCc?: number | null;
model?: string;
type?: 'motorcycle';
year?: number | null;
}ts
export interface Truck {
brand: string;
color: string | null;
createdAt: string;
id: string;
model: string;
payloadCapacity: number | null;
type: string;
updatedAt: string;
year: number | null;
}
export interface TruckCreatePayload {
brand: string;
color?: string | null;
model: string;
payloadCapacity?: number | null;
type: 'truck';
year?: number | null;
}
export interface TruckUpdatePayload {
brand?: string;
color?: string | null;
model?: string;
payloadCapacity?: number | null;
type?: 'truck';
year?: number | null;
}ts
import type {
NullableIntegerFilter,
SortDirection,
StringFilter,
} from '../api';
import type { Car } from './car';
import type { Motorcycle } from './motorcycle';
import type { Truck } from './truck';
export type VehicleType = 'car' | 'motorcycle' | 'truck';
export interface VehicleFilter {
AND?: VehicleFilter[];
brand?: string | StringFilter;
model?: string | StringFilter;
NOT?: VehicleFilter;
OR?: VehicleFilter[];
type?: VehicleTypeFilter;
year?: number | NullableIntegerFilter;
}
export interface VehiclePage {
number?: number;
size?: number;
}
export interface VehicleSort {
year?: SortDirection;
}
export type VehicleTypeFilter =
| VehicleType
| { eq?: VehicleType; in?: VehicleType[] };
export type Vehicle =
| (Car & { type: 'car' })
| (Motorcycle & { type: 'motorcycle' })
| (Truck & { type: 'truck' });ts
export * from './vehicles';ts
import type { OffsetPagination } from '../api';
import type { Car, CarCreatePayload, CarUpdatePayload } from '../domains/car';
import type {
Motorcycle,
MotorcycleCreatePayload,
MotorcycleUpdatePayload,
} from '../domains/motorcycle';
import type {
Truck,
TruckCreatePayload,
TruckUpdatePayload,
} from '../domains/truck';
import type {
Vehicle,
VehicleFilter,
VehiclePage,
VehicleSort,
} from '../domains/vehicle';
export type VehiclesIndexMethod = 'GET';
export type VehiclesIndexPath = '/vehicles';
export interface VehiclesIndexRequestQuery {
filter?: VehicleFilter | VehicleFilter[];
page?: VehiclePage;
sort?: VehicleSort | VehicleSort[];
}
export type VehiclesIndexResponseBody = {
meta?: Record<string, unknown>;
pagination: OffsetPagination;
vehicles: Vehicle[];
};
export interface VehiclesIndexRequest {
query: VehiclesIndexRequestQuery;
}
export interface VehiclesIndexResponse {
body: VehiclesIndexResponseBody;
}
export interface VehiclesIndex {
method: VehiclesIndexMethod;
path: VehiclesIndexPath;
request: VehiclesIndexRequest;
response: VehiclesIndexResponse;
}
export type VehiclesShowMethod = 'GET';
export type VehiclesShowPath = '/vehicles/:id';
export interface VehiclesShowPathParams {
id: string;
}
export type VehiclesShowResponseBody = {
meta?: Record<string, unknown>;
vehicle: Car | Motorcycle | Truck;
};
export interface VehiclesShowResponse {
body: VehiclesShowResponseBody;
}
export interface VehiclesShow {
method: VehiclesShowMethod;
path: VehiclesShowPath;
pathParams: VehiclesShowPathParams;
response: VehiclesShowResponse;
}
export type VehiclesCreateMethod = 'POST';
export type VehiclesCreatePath = '/vehicles';
export interface VehiclesCreateRequestBody {
vehicle: CarCreatePayload | MotorcycleCreatePayload | TruckCreatePayload;
}
export type VehiclesCreateResponseBody = {
meta?: Record<string, unknown>;
vehicle: Car | Motorcycle | Truck;
};
export interface VehiclesCreateRequest {
body: VehiclesCreateRequestBody;
}
export interface VehiclesCreateResponse {
body: VehiclesCreateResponseBody;
}
export type VehiclesCreateErrors = 422;
export interface VehiclesCreate {
errors: VehiclesCreateErrors;
method: VehiclesCreateMethod;
path: VehiclesCreatePath;
request: VehiclesCreateRequest;
response: VehiclesCreateResponse;
}
export type VehiclesUpdateMethod = 'PATCH';
export type VehiclesUpdatePath = '/vehicles/:id';
export interface VehiclesUpdatePathParams {
id: string;
}
export interface VehiclesUpdateRequestBody {
vehicle: CarUpdatePayload | MotorcycleUpdatePayload | TruckUpdatePayload;
}
export type VehiclesUpdateResponseBody = {
meta?: Record<string, unknown>;
vehicle: Car | Motorcycle | Truck;
};
export interface VehiclesUpdateRequest {
body: VehiclesUpdateRequestBody;
}
export interface VehiclesUpdateResponse {
body: VehiclesUpdateResponseBody;
}
export type VehiclesUpdateErrors = 422;
export interface VehiclesUpdate {
errors: VehiclesUpdateErrors;
method: VehiclesUpdateMethod;
path: VehiclesUpdatePath;
pathParams: VehiclesUpdatePathParams;
request: VehiclesUpdateRequest;
response: VehiclesUpdateResponse;
}
export type VehiclesDestroyMethod = 'DELETE';
export type VehiclesDestroyPath = '/vehicles/:id';
export interface VehiclesDestroyPathParams {
id: string;
}
export interface VehiclesDestroy {
method: VehiclesDestroyMethod;
path: VehiclesDestroyPath;
pathParams: VehiclesDestroyPathParams;
}Zod
ts
import * as z from 'zod';
export const ErrorLayerSchema = z.enum(['contract', 'domain', 'http']);
export const SortDirectionSchema = z.enum(['asc', 'desc']);
export const ErrorIssueSchema = z.object({
code: z.string(),
detail: z.string(),
meta: z.record(z.string(), z.unknown()),
path: z.array(z.union([z.string(), z.number().int()])),
pointer: z.string(),
});
export const IntegerFilterBetweenSchema = z.object({
from: z.number().int().optional(),
to: z.number().int().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 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 ErrorSchema = z.object({
issues: z.array(ErrorIssueSchema),
layer: ErrorLayerSchema,
});
export const NullableIntegerFilterSchema = z.object({
between: IntegerFilterBetweenSchema.optional(),
eq: z.number().int().optional(),
gt: z.number().int().optional(),
gte: z.number().int().optional(),
in: z.array(z.number().int()).optional(),
lt: z.number().int().optional(),
lte: z.number().int().optional(),
null: z.boolean().optional(),
});
export type ErrorLayer = 'contract' | 'domain' | 'http';
export type SortDirection = 'asc' | 'desc';
export interface ErrorIssue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string | number[];
pointer: string;
}
export interface IntegerFilterBetween {
from?: number;
to?: number;
}
export interface OffsetPagination {
current: number;
items: number;
next?: number | null;
prev?: number | null;
total: number;
}
export interface StringFilter {
contains?: string;
endsWith?: string;
eq?: string;
in?: string[];
startsWith?: string;
}
export interface Error {
issues: ErrorIssue[];
layer: ErrorLayer;
}
export interface NullableIntegerFilter {
between?: IntegerFilterBetween;
eq?: number;
gt?: number;
gte?: number;
in?: number[];
lt?: number;
lte?: number;
null?: boolean;
}ts
import * as z from 'zod';
export const CarSchema = z.object({
brand: z.string(),
color: z.string().nullable(),
createdAt: z.iso.datetime(),
doors: z.number().int().nullable(),
id: z.string(),
model: z.string(),
type: z.string(),
updatedAt: z.iso.datetime(),
year: z.number().int().nullable(),
});
export const CarCreatePayloadSchema = z.object({
brand: z.string(),
color: z.string().nullable().default(null),
doors: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
model: z.string(),
type: z.literal('car'),
year: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
});
export const CarUpdatePayloadSchema = z.object({
brand: z.string().optional(),
color: z.string().nullable().optional(),
doors: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.optional(),
model: z.string().optional(),
type: z.literal('car').optional(),
year: z.number().int().min(-2147483648).max(2147483647).nullable().optional(),
});
export interface Car {
brand: string;
color: string | null;
createdAt: string;
doors: number | null;
id: string;
model: string;
type: string;
updatedAt: string;
year: number | null;
}
export interface CarCreatePayload {
brand: string;
color?: string | null;
doors?: number | null;
model: string;
type: 'car';
year?: number | null;
}
export interface CarUpdatePayload {
brand?: string;
color?: string | null;
doors?: number | null;
model?: string;
type?: 'car';
year?: number | null;
}ts
export * from './car';
export * from './motorcycle';
export * from './truck';
export * from './vehicle';ts
import * as z from 'zod';
export const MotorcycleSchema = z.object({
brand: z.string(),
color: z.string().nullable(),
createdAt: z.iso.datetime(),
engineCc: z.number().int().nullable(),
id: z.string(),
model: z.string(),
type: z.string(),
updatedAt: z.iso.datetime(),
year: z.number().int().nullable(),
});
export const MotorcycleCreatePayloadSchema = z.object({
brand: z.string(),
color: z.string().nullable().default(null),
engineCc: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
model: z.string(),
type: z.literal('motorcycle'),
year: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
});
export const MotorcycleUpdatePayloadSchema = z.object({
brand: z.string().optional(),
color: z.string().nullable().optional(),
engineCc: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.optional(),
model: z.string().optional(),
type: z.literal('motorcycle').optional(),
year: z.number().int().min(-2147483648).max(2147483647).nullable().optional(),
});
export interface Motorcycle {
brand: string;
color: string | null;
createdAt: string;
engineCc: number | null;
id: string;
model: string;
type: string;
updatedAt: string;
year: number | null;
}
export interface MotorcycleCreatePayload {
brand: string;
color?: string | null;
engineCc?: number | null;
model: string;
type: 'motorcycle';
year?: number | null;
}
export interface MotorcycleUpdatePayload {
brand?: string;
color?: string | null;
engineCc?: number | null;
model?: string;
type?: 'motorcycle';
year?: number | null;
}ts
import * as z from 'zod';
export const TruckSchema = z.object({
brand: z.string(),
color: z.string().nullable(),
createdAt: z.iso.datetime(),
id: z.string(),
model: z.string(),
payloadCapacity: z.number().nullable(),
type: z.string(),
updatedAt: z.iso.datetime(),
year: z.number().int().nullable(),
});
export const TruckCreatePayloadSchema = z.object({
brand: z.string(),
color: z.string().nullable().default(null),
model: z.string(),
payloadCapacity: z
.number()
.min(-99999999.99)
.max(99999999.99)
.nullable()
.default(null),
type: z.literal('truck'),
year: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
});
export const TruckUpdatePayloadSchema = z.object({
brand: z.string().optional(),
color: z.string().nullable().optional(),
model: z.string().optional(),
payloadCapacity: z
.number()
.min(-99999999.99)
.max(99999999.99)
.nullable()
.optional(),
type: z.literal('truck').optional(),
year: z.number().int().min(-2147483648).max(2147483647).nullable().optional(),
});
export interface Truck {
brand: string;
color: string | null;
createdAt: string;
id: string;
model: string;
payloadCapacity: number | null;
type: string;
updatedAt: string;
year: number | null;
}
export interface TruckCreatePayload {
brand: string;
color?: string | null;
model: string;
payloadCapacity?: number | null;
type: 'truck';
year?: number | null;
}
export interface TruckUpdatePayload {
brand?: string;
color?: string | null;
model?: string;
payloadCapacity?: number | null;
type?: 'truck';
year?: number | null;
}ts
import type {
NullableIntegerFilter,
SortDirection,
StringFilter,
} from '../api';
import type { Car } from './car';
import type { Motorcycle } from './motorcycle';
import type { Truck } from './truck';
import * as z from 'zod';
import {
NullableIntegerFilterSchema,
SortDirectionSchema,
StringFilterSchema,
} from '../api';
import { CarSchema } from './car';
import { MotorcycleSchema } from './motorcycle';
import { TruckSchema } from './truck';
export const VehicleTypeSchema = z.enum(['car', 'motorcycle', 'truck']);
export const VehicleFilterSchema: z.ZodType<VehicleFilter> = z.lazy(() =>
z.object({
AND: z.array(VehicleFilterSchema).optional(),
brand: z.union([z.string(), StringFilterSchema]).optional(),
model: z.union([z.string(), StringFilterSchema]).optional(),
NOT: VehicleFilterSchema.optional(),
OR: z.array(VehicleFilterSchema).optional(),
type: VehicleTypeFilterSchema.optional(),
year: z.union([z.number().int(), NullableIntegerFilterSchema]).optional(),
}),
);
export const VehiclePageSchema = z.object({
number: z.number().int().min(1).optional(),
size: z.number().int().min(1).max(100).optional(),
});
export const VehicleSortSchema = z.object({
year: SortDirectionSchema.optional(),
});
export const VehicleTypeFilterSchema = z.union([
VehicleTypeSchema,
z.object({ eq: VehicleTypeSchema, in: z.array(VehicleTypeSchema) }).partial(),
]);
export const VehicleSchema = z.discriminatedUnion('type', [
CarSchema.extend({ type: z.literal('car') }),
MotorcycleSchema.extend({ type: z.literal('motorcycle') }),
TruckSchema.extend({ type: z.literal('truck') }),
]);
export type VehicleType = 'car' | 'motorcycle' | 'truck';
export interface VehicleFilter {
AND?: VehicleFilter[];
brand?: string | StringFilter;
model?: string | StringFilter;
NOT?: VehicleFilter;
OR?: VehicleFilter[];
type?: VehicleTypeFilter;
year?: number | NullableIntegerFilter;
}
export interface VehiclePage {
number?: number;
size?: number;
}
export interface VehicleSort {
year?: SortDirection;
}
export type VehicleTypeFilter =
| VehicleType
| { eq?: VehicleType; in?: VehicleType[] };
export type Vehicle =
| (Car & { type: 'car' })
| (Motorcycle & { type: 'motorcycle' })
| (Truck & { type: 'truck' });ts
export * from './vehicles';ts
import type { OffsetPagination } from '../api';
import type { Car, CarCreatePayload, CarUpdatePayload } from '../domains/car';
import type {
Motorcycle,
MotorcycleCreatePayload,
MotorcycleUpdatePayload,
} from '../domains/motorcycle';
import type {
Truck,
TruckCreatePayload,
TruckUpdatePayload,
} from '../domains/truck';
import type {
Vehicle,
VehicleFilter,
VehiclePage,
VehicleSort,
} from '../domains/vehicle';
import * as z from 'zod';
import { OffsetPaginationSchema } from '../api';
import {
CarCreatePayloadSchema,
CarSchema,
CarUpdatePayloadSchema,
} from '../domains/car';
import {
MotorcycleCreatePayloadSchema,
MotorcycleSchema,
MotorcycleUpdatePayloadSchema,
} from '../domains/motorcycle';
import {
TruckCreatePayloadSchema,
TruckSchema,
TruckUpdatePayloadSchema,
} from '../domains/truck';
import {
VehicleFilterSchema,
VehiclePageSchema,
VehicleSchema,
VehicleSortSchema,
} from '../domains/vehicle';
export const VehiclesIndexRequestQuerySchema = z.object({
filter: z
.union([VehicleFilterSchema, z.array(VehicleFilterSchema)])
.optional(),
page: VehiclePageSchema.optional(),
sort: z.union([VehicleSortSchema, z.array(VehicleSortSchema)]).optional(),
});
export const VehiclesIndexResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
pagination: OffsetPaginationSchema,
vehicles: z.array(VehicleSchema),
});
export const VehiclesShowPathParamsSchema = z.object({ id: z.string() });
export const VehiclesShowResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
vehicle: z.discriminatedUnion('type', [
CarSchema,
MotorcycleSchema,
TruckSchema,
]),
});
export const VehiclesCreateRequestBodySchema = z.object({
vehicle: z.discriminatedUnion('type', [
CarCreatePayloadSchema,
MotorcycleCreatePayloadSchema,
TruckCreatePayloadSchema,
]),
});
export const VehiclesCreateResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
vehicle: z.discriminatedUnion('type', [
CarSchema,
MotorcycleSchema,
TruckSchema,
]),
});
export const VehiclesUpdatePathParamsSchema = z.object({ id: z.string() });
export const VehiclesUpdateRequestBodySchema = z.object({
vehicle: z.discriminatedUnion('type', [
CarUpdatePayloadSchema,
MotorcycleUpdatePayloadSchema,
TruckUpdatePayloadSchema,
]),
});
export const VehiclesUpdateResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
vehicle: z.discriminatedUnion('type', [
CarSchema,
MotorcycleSchema,
TruckSchema,
]),
});
export const VehiclesDestroyPathParamsSchema = z.object({ id: z.string() });
export type VehiclesIndexMethod = 'GET';
export type VehiclesIndexPath = '/vehicles';
export interface VehiclesIndexRequestQuery {
filter?: VehicleFilter | VehicleFilter[];
page?: VehiclePage;
sort?: VehicleSort | VehicleSort[];
}
export type VehiclesIndexResponseBody = {
meta?: Record<string, unknown>;
pagination: OffsetPagination;
vehicles: Vehicle[];
};
export interface VehiclesIndexRequest {
query: VehiclesIndexRequestQuery;
}
export interface VehiclesIndexResponse {
body: VehiclesIndexResponseBody;
}
export interface VehiclesIndex {
method: VehiclesIndexMethod;
path: VehiclesIndexPath;
request: VehiclesIndexRequest;
response: VehiclesIndexResponse;
}
export type VehiclesShowMethod = 'GET';
export type VehiclesShowPath = '/vehicles/:id';
export interface VehiclesShowPathParams {
id: string;
}
export type VehiclesShowResponseBody = {
meta?: Record<string, unknown>;
vehicle: Car | Motorcycle | Truck;
};
export interface VehiclesShowResponse {
body: VehiclesShowResponseBody;
}
export interface VehiclesShow {
method: VehiclesShowMethod;
path: VehiclesShowPath;
pathParams: VehiclesShowPathParams;
response: VehiclesShowResponse;
}
export type VehiclesCreateMethod = 'POST';
export type VehiclesCreatePath = '/vehicles';
export interface VehiclesCreateRequestBody {
vehicle: CarCreatePayload | MotorcycleCreatePayload | TruckCreatePayload;
}
export type VehiclesCreateResponseBody = {
meta?: Record<string, unknown>;
vehicle: Car | Motorcycle | Truck;
};
export interface VehiclesCreateRequest {
body: VehiclesCreateRequestBody;
}
export interface VehiclesCreateResponse {
body: VehiclesCreateResponseBody;
}
export type VehiclesCreateErrors = 422;
export interface VehiclesCreate {
errors: VehiclesCreateErrors;
method: VehiclesCreateMethod;
path: VehiclesCreatePath;
request: VehiclesCreateRequest;
response: VehiclesCreateResponse;
}
export type VehiclesUpdateMethod = 'PATCH';
export type VehiclesUpdatePath = '/vehicles/:id';
export interface VehiclesUpdatePathParams {
id: string;
}
export interface VehiclesUpdateRequestBody {
vehicle: CarUpdatePayload | MotorcycleUpdatePayload | TruckUpdatePayload;
}
export type VehiclesUpdateResponseBody = {
meta?: Record<string, unknown>;
vehicle: Car | Motorcycle | Truck;
};
export interface VehiclesUpdateRequest {
body: VehiclesUpdateRequestBody;
}
export interface VehiclesUpdateResponse {
body: VehiclesUpdateResponseBody;
}
export type VehiclesUpdateErrors = 422;
export interface VehiclesUpdate {
errors: VehiclesUpdateErrors;
method: VehiclesUpdateMethod;
path: VehiclesUpdatePath;
pathParams: VehiclesUpdatePathParams;
request: VehiclesUpdateRequest;
response: VehiclesUpdateResponse;
}
export type VehiclesDestroyMethod = 'DELETE';
export type VehiclesDestroyPath = '/vehicles/:id';
export interface VehiclesDestroyPathParams {
id: string;
}
export interface VehiclesDestroy {
method: VehiclesDestroyMethod;
path: VehiclesDestroyPath;
pathParams: VehiclesDestroyPathParams;
}Sorbus
ts
import * as z from 'zod';
export const ErrorLayerSchema = z.enum(['contract', 'domain', 'http']);
export const SortDirectionSchema = z.enum(['asc', 'desc']);
export const ErrorIssueSchema = z.object({
code: z.string(),
detail: z.string(),
meta: z.record(z.string(), z.unknown()),
path: z.array(z.union([z.string(), z.number().int()])),
pointer: z.string(),
});
export const IntegerFilterBetweenSchema = z.object({
from: z.number().int().optional(),
to: z.number().int().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 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 ErrorSchema = z.object({
issues: z.array(ErrorIssueSchema),
layer: ErrorLayerSchema,
});
export const NullableIntegerFilterSchema = z.object({
between: IntegerFilterBetweenSchema.optional(),
eq: z.number().int().optional(),
gt: z.number().int().optional(),
gte: z.number().int().optional(),
in: z.array(z.number().int()).optional(),
lt: z.number().int().optional(),
lte: z.number().int().optional(),
null: z.boolean().optional(),
});
export type ErrorLayer = 'contract' | 'domain' | 'http';
export type SortDirection = 'asc' | 'desc';
export interface ErrorIssue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string | number[];
pointer: string;
}
export interface IntegerFilterBetween {
from?: number;
to?: number;
}
export interface OffsetPagination {
current: number;
items: number;
next?: number | null;
prev?: number | null;
total: number;
}
export interface StringFilter {
contains?: string;
endsWith?: string;
eq?: string;
in?: string[];
startsWith?: string;
}
export interface Error {
issues: ErrorIssue[];
layer: ErrorLayer;
}
export interface NullableIntegerFilter {
between?: IntegerFilterBetween;
eq?: number;
gt?: number;
gte?: number;
in?: number[];
lt?: number;
lte?: number;
null?: boolean;
}ts
import type { VehiclesOperationTree } from './endpoints';
import { createClientFactory } from 'sorbus';
import { contract } from './contract';
export interface Client {
vehicles: VehiclesOperationTree;
}
export const createClient = createClientFactory<Client>(contract);ts
import { ErrorSchema } from './api';
import { vehicles } from './endpoints';
export const contract = {
endpoints: {
vehicles,
},
error: ErrorSchema,
} as const;ts
import * as z from 'zod';
export const CarSchema = z.object({
brand: z.string(),
color: z.string().nullable(),
createdAt: z.iso.datetime(),
doors: z.number().int().nullable(),
id: z.string(),
model: z.string(),
type: z.string(),
updatedAt: z.iso.datetime(),
year: z.number().int().nullable(),
});
export const CarCreatePayloadSchema = z.object({
brand: z.string(),
color: z.string().nullable().default(null),
doors: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
model: z.string(),
type: z.literal('car'),
year: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
});
export const CarUpdatePayloadSchema = z.object({
brand: z.string().optional(),
color: z.string().nullable().optional(),
doors: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.optional(),
model: z.string().optional(),
type: z.literal('car').optional(),
year: z.number().int().min(-2147483648).max(2147483647).nullable().optional(),
});
export interface Car {
brand: string;
color: string | null;
createdAt: string;
doors: number | null;
id: string;
model: string;
type: string;
updatedAt: string;
year: number | null;
}
export interface CarCreatePayload {
brand: string;
color?: string | null;
doors?: number | null;
model: string;
type: 'car';
year?: number | null;
}
export interface CarUpdatePayload {
brand?: string;
color?: string | null;
doors?: number | null;
model?: string;
type?: 'car';
year?: number | null;
}ts
export * from './car';
export * from './motorcycle';
export * from './truck';
export * from './vehicle';ts
import * as z from 'zod';
export const MotorcycleSchema = z.object({
brand: z.string(),
color: z.string().nullable(),
createdAt: z.iso.datetime(),
engineCc: z.number().int().nullable(),
id: z.string(),
model: z.string(),
type: z.string(),
updatedAt: z.iso.datetime(),
year: z.number().int().nullable(),
});
export const MotorcycleCreatePayloadSchema = z.object({
brand: z.string(),
color: z.string().nullable().default(null),
engineCc: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
model: z.string(),
type: z.literal('motorcycle'),
year: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
});
export const MotorcycleUpdatePayloadSchema = z.object({
brand: z.string().optional(),
color: z.string().nullable().optional(),
engineCc: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.optional(),
model: z.string().optional(),
type: z.literal('motorcycle').optional(),
year: z.number().int().min(-2147483648).max(2147483647).nullable().optional(),
});
export interface Motorcycle {
brand: string;
color: string | null;
createdAt: string;
engineCc: number | null;
id: string;
model: string;
type: string;
updatedAt: string;
year: number | null;
}
export interface MotorcycleCreatePayload {
brand: string;
color?: string | null;
engineCc?: number | null;
model: string;
type: 'motorcycle';
year?: number | null;
}
export interface MotorcycleUpdatePayload {
brand?: string;
color?: string | null;
engineCc?: number | null;
model?: string;
type?: 'motorcycle';
year?: number | null;
}ts
import * as z from 'zod';
export const TruckSchema = z.object({
brand: z.string(),
color: z.string().nullable(),
createdAt: z.iso.datetime(),
id: z.string(),
model: z.string(),
payloadCapacity: z.number().nullable(),
type: z.string(),
updatedAt: z.iso.datetime(),
year: z.number().int().nullable(),
});
export const TruckCreatePayloadSchema = z.object({
brand: z.string(),
color: z.string().nullable().default(null),
model: z.string(),
payloadCapacity: z
.number()
.min(-99999999.99)
.max(99999999.99)
.nullable()
.default(null),
type: z.literal('truck'),
year: z
.number()
.int()
.min(-2147483648)
.max(2147483647)
.nullable()
.default(null),
});
export const TruckUpdatePayloadSchema = z.object({
brand: z.string().optional(),
color: z.string().nullable().optional(),
model: z.string().optional(),
payloadCapacity: z
.number()
.min(-99999999.99)
.max(99999999.99)
.nullable()
.optional(),
type: z.literal('truck').optional(),
year: z.number().int().min(-2147483648).max(2147483647).nullable().optional(),
});
export interface Truck {
brand: string;
color: string | null;
createdAt: string;
id: string;
model: string;
payloadCapacity: number | null;
type: string;
updatedAt: string;
year: number | null;
}
export interface TruckCreatePayload {
brand: string;
color?: string | null;
model: string;
payloadCapacity?: number | null;
type: 'truck';
year?: number | null;
}
export interface TruckUpdatePayload {
brand?: string;
color?: string | null;
model?: string;
payloadCapacity?: number | null;
type?: 'truck';
year?: number | null;
}ts
import type {
NullableIntegerFilter,
SortDirection,
StringFilter,
} from '../api';
import type { Car } from './car';
import type { Motorcycle } from './motorcycle';
import type { Truck } from './truck';
import * as z from 'zod';
import {
NullableIntegerFilterSchema,
SortDirectionSchema,
StringFilterSchema,
} from '../api';
import { CarSchema } from './car';
import { MotorcycleSchema } from './motorcycle';
import { TruckSchema } from './truck';
export const VehicleTypeSchema = z.enum(['car', 'motorcycle', 'truck']);
export const VehicleFilterSchema: z.ZodType<VehicleFilter> = z.lazy(() =>
z.object({
AND: z.array(VehicleFilterSchema).optional(),
brand: z.union([z.string(), StringFilterSchema]).optional(),
model: z.union([z.string(), StringFilterSchema]).optional(),
NOT: VehicleFilterSchema.optional(),
OR: z.array(VehicleFilterSchema).optional(),
type: VehicleTypeFilterSchema.optional(),
year: z.union([z.number().int(), NullableIntegerFilterSchema]).optional(),
}),
);
export const VehiclePageSchema = z.object({
number: z.number().int().min(1).optional(),
size: z.number().int().min(1).max(100).optional(),
});
export const VehicleSortSchema = z.object({
year: SortDirectionSchema.optional(),
});
export const VehicleTypeFilterSchema = z.union([
VehicleTypeSchema,
z.object({ eq: VehicleTypeSchema, in: z.array(VehicleTypeSchema) }).partial(),
]);
export const VehicleSchema = z.discriminatedUnion('type', [
CarSchema.extend({ type: z.literal('car') }),
MotorcycleSchema.extend({ type: z.literal('motorcycle') }),
TruckSchema.extend({ type: z.literal('truck') }),
]);
export type VehicleType = 'car' | 'motorcycle' | 'truck';
export interface VehicleFilter {
AND?: VehicleFilter[];
brand?: string | StringFilter;
model?: string | StringFilter;
NOT?: VehicleFilter;
OR?: VehicleFilter[];
type?: VehicleTypeFilter;
year?: number | NullableIntegerFilter;
}
export interface VehiclePage {
number?: number;
size?: number;
}
export interface VehicleSort {
year?: SortDirection;
}
export type VehicleTypeFilter =
| VehicleType
| { eq?: VehicleType; in?: VehicleType[] };
export type Vehicle =
| (Car & { type: 'car' })
| (Motorcycle & { type: 'motorcycle' })
| (Truck & { type: 'truck' });ts
export * from './vehicles';ts
import type { Operation } from 'sorbus';
import type { OffsetPagination } from '../api';
import type { Car, CarCreatePayload, CarUpdatePayload } from '../domains/car';
import type {
Motorcycle,
MotorcycleCreatePayload,
MotorcycleUpdatePayload,
} from '../domains/motorcycle';
import type {
Truck,
TruckCreatePayload,
TruckUpdatePayload,
} from '../domains/truck';
import type {
Vehicle,
VehicleFilter,
VehiclePage,
VehicleSort,
} from '../domains/vehicle';
import * as z from 'zod';
import { OffsetPaginationSchema } from '../api';
import {
CarCreatePayloadSchema,
CarSchema,
CarUpdatePayloadSchema,
} from '../domains/car';
import {
MotorcycleCreatePayloadSchema,
MotorcycleSchema,
MotorcycleUpdatePayloadSchema,
} from '../domains/motorcycle';
import {
TruckCreatePayloadSchema,
TruckSchema,
TruckUpdatePayloadSchema,
} from '../domains/truck';
import {
VehicleFilterSchema,
VehiclePageSchema,
VehicleSchema,
VehicleSortSchema,
} from '../domains/vehicle';
export const VehiclesIndexRequestQuerySchema = z.object({
filter: z
.union([VehicleFilterSchema, z.array(VehicleFilterSchema)])
.optional(),
page: VehiclePageSchema.optional(),
sort: z.union([VehicleSortSchema, z.array(VehicleSortSchema)]).optional(),
});
export const VehiclesIndexResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
pagination: OffsetPaginationSchema,
vehicles: z.array(VehicleSchema),
});
export const VehiclesShowPathParamsSchema = z.object({ id: z.string() });
export const VehiclesShowResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
vehicle: z.discriminatedUnion('type', [
CarSchema,
MotorcycleSchema,
TruckSchema,
]),
});
export const VehiclesCreateRequestBodySchema = z.object({
vehicle: z.discriminatedUnion('type', [
CarCreatePayloadSchema,
MotorcycleCreatePayloadSchema,
TruckCreatePayloadSchema,
]),
});
export const VehiclesCreateResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
vehicle: z.discriminatedUnion('type', [
CarSchema,
MotorcycleSchema,
TruckSchema,
]),
});
export const VehiclesUpdatePathParamsSchema = z.object({ id: z.string() });
export const VehiclesUpdateRequestBodySchema = z.object({
vehicle: z.discriminatedUnion('type', [
CarUpdatePayloadSchema,
MotorcycleUpdatePayloadSchema,
TruckUpdatePayloadSchema,
]),
});
export const VehiclesUpdateResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
vehicle: z.discriminatedUnion('type', [
CarSchema,
MotorcycleSchema,
TruckSchema,
]),
});
export const VehiclesDestroyPathParamsSchema = z.object({ id: z.string() });
export type VehiclesIndexMethod = 'GET';
export type VehiclesIndexPath = '/vehicles';
export interface VehiclesIndexRequestQuery {
filter?: VehicleFilter | VehicleFilter[];
page?: VehiclePage;
sort?: VehicleSort | VehicleSort[];
}
export type VehiclesIndexResponseBody = {
meta?: Record<string, unknown>;
pagination: OffsetPagination;
vehicles: Vehicle[];
};
export interface VehiclesIndexRequest {
query: VehiclesIndexRequestQuery;
}
export interface VehiclesIndexResponse {
body: VehiclesIndexResponseBody;
}
export interface VehiclesIndex {
method: VehiclesIndexMethod;
path: VehiclesIndexPath;
request: VehiclesIndexRequest;
response: VehiclesIndexResponse;
}
export type VehiclesShowMethod = 'GET';
export type VehiclesShowPath = '/vehicles/:id';
export interface VehiclesShowPathParams {
id: string;
}
export type VehiclesShowResponseBody = {
meta?: Record<string, unknown>;
vehicle: Car | Motorcycle | Truck;
};
export interface VehiclesShowResponse {
body: VehiclesShowResponseBody;
}
export interface VehiclesShow {
method: VehiclesShowMethod;
path: VehiclesShowPath;
pathParams: VehiclesShowPathParams;
response: VehiclesShowResponse;
}
export type VehiclesCreateMethod = 'POST';
export type VehiclesCreatePath = '/vehicles';
export interface VehiclesCreateRequestBody {
vehicle: CarCreatePayload | MotorcycleCreatePayload | TruckCreatePayload;
}
export type VehiclesCreateResponseBody = {
meta?: Record<string, unknown>;
vehicle: Car | Motorcycle | Truck;
};
export interface VehiclesCreateRequest {
body: VehiclesCreateRequestBody;
}
export interface VehiclesCreateResponse {
body: VehiclesCreateResponseBody;
}
export type VehiclesCreateErrors = 422;
export interface VehiclesCreate {
errors: VehiclesCreateErrors;
method: VehiclesCreateMethod;
path: VehiclesCreatePath;
request: VehiclesCreateRequest;
response: VehiclesCreateResponse;
}
export type VehiclesUpdateMethod = 'PATCH';
export type VehiclesUpdatePath = '/vehicles/:id';
export interface VehiclesUpdatePathParams {
id: string;
}
export interface VehiclesUpdateRequestBody {
vehicle: CarUpdatePayload | MotorcycleUpdatePayload | TruckUpdatePayload;
}
export type VehiclesUpdateResponseBody = {
meta?: Record<string, unknown>;
vehicle: Car | Motorcycle | Truck;
};
export interface VehiclesUpdateRequest {
body: VehiclesUpdateRequestBody;
}
export interface VehiclesUpdateResponse {
body: VehiclesUpdateResponseBody;
}
export type VehiclesUpdateErrors = 422;
export interface VehiclesUpdate {
errors: VehiclesUpdateErrors;
method: VehiclesUpdateMethod;
path: VehiclesUpdatePath;
pathParams: VehiclesUpdatePathParams;
request: VehiclesUpdateRequest;
response: VehiclesUpdateResponse;
}
export type VehiclesDestroyMethod = 'DELETE';
export type VehiclesDestroyPath = '/vehicles/:id';
export interface VehiclesDestroyPathParams {
id: string;
}
export interface VehiclesDestroy {
method: VehiclesDestroyMethod;
path: VehiclesDestroyPath;
pathParams: VehiclesDestroyPathParams;
}
export const vehicles = {
create: {
errors: [422],
method: 'POST',
path: '/vehicles',
request: {
body: VehiclesCreateRequestBodySchema,
},
response: {
body: VehiclesCreateResponseBodySchema,
},
},
destroy: {
method: 'DELETE',
path: '/vehicles/:id',
pathParams: VehiclesDestroyPathParamsSchema,
},
index: {
method: 'GET',
path: '/vehicles',
request: {
query: VehiclesIndexRequestQuerySchema,
},
response: {
body: VehiclesIndexResponseBodySchema,
},
},
show: {
method: 'GET',
path: '/vehicles/:id',
pathParams: VehiclesShowPathParamsSchema,
response: {
body: VehiclesShowResponseBodySchema,
},
},
update: {
errors: [422],
method: 'PATCH',
path: '/vehicles/:id',
pathParams: VehiclesUpdatePathParamsSchema,
request: {
body: VehiclesUpdateRequestBodySchema,
},
response: {
body: VehiclesUpdateResponseBodySchema,
},
},
} as const;
export interface VehiclesOperationTree {
create: Operation<VehiclesCreate>;
destroy: Operation<VehiclesDestroy>;
index: Operation<VehiclesIndex>;
show: Operation<VehiclesShow>;
update: Operation<VehiclesUpdate>;
}