Documentation I18n
Translatable API documentation with built-in I18n support
API Definition
config/apis/wise_tiger.rb
rb
# frozen_string_literal: true
Apiwork::API.define '/wise_tiger' do
key_format :camel
export :openapi
export :apiwork
info do
version '1.0.0'
end
resources :projects
endModels
app/models/wise_tiger/project.rb
rb
# frozen_string_literal: true
module WiseTiger
class Project < ApplicationRecord
enum :status, { active: 0, archived: 1, completed: 2, paused: 3 }
enum :priority, { low: 0, medium: 1, high: 2, critical: 3 }
validates :name, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| created_at | datetime | ||
| deadline | date | ✓ | |
| description | text | ✓ | |
| name | string | ||
| priority | integer | 1 | |
| status | integer | 0 | |
| updated_at | datetime |
Representations
app/representations/wise_tiger/project_representation.rb
rb
# frozen_string_literal: true
module WiseTiger
class ProjectRepresentation < Apiwork::Representation::Base
attribute :id
attribute :name, writable: true
attribute :description, writable: true
attribute :status, filterable: true, writable: true
attribute :priority, filterable: true, writable: true
attribute :deadline, sortable: true, writable: true
attribute :created_at, sortable: true
attribute :updated_at, sortable: true
end
endContracts
app/contracts/wise_tiger/project_contract.rb
rb
# frozen_string_literal: true
module WiseTiger
class ProjectContract < Apiwork::Contract::Base
representation ProjectRepresentation
end
endControllers
app/controllers/wise_tiger/projects_controller.rb
rb
# frozen_string_literal: true
module WiseTiger
class ProjectsController < ApplicationController
before_action :set_project, only: %i[show update destroy]
def index
projects = Project.all
expose projects
end
def show
expose project
end
def create
project = Project.create(contract.body[:project])
expose project
end
def update
project.update(contract.body[:project])
expose project
end
def destroy
project.destroy
expose project
end
private
attr_reader :project
def set_project
@project = Project.find(params[:id])
end
end
endLocales
config/locales/wise_tiger.en.yml
yml
en:
apiwork:
apis:
wise_tiger:
info:
title: Project Management API
description: API for managing projects with I18n-powered documentation
contracts:
project:
actions:
index:
summary: List all projects
description: Returns a paginated list of projects with optional filtering
show:
summary: Get project details
description: Returns a single project by ID with all attributes
create:
summary: Create a new project
description: Creates a project and returns the created resource
update:
summary: Update a project
description: Updates an existing project with the provided attributes
destroy:
summary: Delete a project
description: Permanently removes a project
representations:
project:
attributes:
id:
description: Unique project identifier
name:
description: Human-readable project name
description:
description: Detailed project description
status:
description: Current project lifecycle status
priority:
description: Project priority for resource allocation
deadline:
description: Target completion date
created_at:
description: Timestamp when project was created
updated_at:
description: Timestamp of last modificationRequest Examples
List all projects
Request
http
GET /wise_tiger/projectsResponse 200
json
{
"projects": [
{
"id": "48b9294b-b5f6-51ea-9c77-a28d821b337d",
"name": "Website Redesign",
"description": "Complete overhaul of the company website",
"status": "active",
"priority": "high",
"deadline": null,
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
},
{
"id": "37e7aaed-3cb7-5641-b7be-3e698b300b7c",
"name": "Mobile App",
"description": "Native iOS and Android apps",
"status": "paused",
"priority": "medium",
"deadline": null,
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
}
],
"pagination": {
"items": 2,
"total": 1,
"current": 1,
"next": null,
"prev": null
}
}Get project details
Request
http
GET /wise_tiger/projects/48b9294b-b5f6-51ea-9c77-a28d821b337dResponse 200
json
{
"project": {
"id": "48b9294b-b5f6-51ea-9c77-a28d821b337d",
"name": "API Integration",
"description": "Connect to third-party services",
"status": "active",
"priority": "critical",
"deadline": "2024-06-01",
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
}
}Create a project
Request
http
POST /wise_tiger/projects
Content-Type: application/json
{
"project": {
"name": "New Feature",
"description": "Implement the new dashboard",
"status": "active",
"priority": "high",
"deadline": "2024-03-15"
}
}Response 201
json
{
"project": {
"id": "48b9294b-b5f6-51ea-9c77-a28d821b337d",
"name": "New Feature",
"description": "Implement the new dashboard",
"status": "active",
"priority": "high",
"deadline": "2024-03-15",
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
}
}Exports
OpenAPI
yml
---
openapi: 3.1.0
info:
description: API for managing projects with I18n-powered documentation
title: Project Management API
version: 1.0.0
paths:
"/projects":
get:
description: Returns a paginated list of projects with optional filtering
operationId: projectsIndex
summary: List all projects
parameters:
- in: query
name: filter
required: false
schema:
oneOf:
- "$ref": "#/components/schemas/projectFilter"
- items:
"$ref": "#/components/schemas/projectFilter"
type: array
- in: query
name: page
required: false
schema:
"$ref": "#/components/schemas/projectPage"
- in: query
name: sort
required: false
schema:
oneOf:
- "$ref": "#/components/schemas/projectSort"
- items:
"$ref": "#/components/schemas/projectSort"
type: array
responses:
'200':
content:
application/json:
schema:
properties:
meta:
properties: {}
type: object
pagination:
"$ref": "#/components/schemas/offsetPagination"
projects:
items:
"$ref": "#/components/schemas/project"
type: array
type: object
required:
- pagination
- projects
description: ''
post:
description: Creates a project and returns the created resource
operationId: projectsCreate
summary: Create a new project
requestBody:
content:
application/json:
schema:
properties:
project:
"$ref": "#/components/schemas/projectCreatePayload"
type: object
required:
- project
required: true
responses:
'200':
content:
application/json:
schema:
properties:
meta:
properties: {}
type: object
project:
"$ref": "#/components/schemas/project"
type: object
required:
- project
description: ''
'422':
description: Unprocessable Entity
content:
application/json:
schema:
properties:
issues:
items:
"$ref": "#/components/schemas/error"
type: array
required:
- issues
type: object
"/projects/{id}":
get:
description: Returns a single project by ID with all attributes
operationId: projectsShow
summary: Get project details
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
properties:
meta:
properties: {}
type: object
project:
"$ref": "#/components/schemas/project"
type: object
required:
- project
description: ''
patch:
description: Updates an existing project with the provided attributes
operationId: projectsUpdate
summary: Update a project
parameters:
- in: path
name: id
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
project:
"$ref": "#/components/schemas/projectUpdatePayload"
type: object
required:
- project
required: true
responses:
'200':
content:
application/json:
schema:
properties:
meta:
properties: {}
type: object
project:
"$ref": "#/components/schemas/project"
type: object
required:
- project
description: ''
'422':
description: Unprocessable Entity
content:
application/json:
schema:
properties:
issues:
items:
"$ref": "#/components/schemas/error"
type: array
required:
- issues
type: object
delete:
description: Permanently removes a project
operationId: projectsDestroy
summary: Delete a project
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'204':
description: ''
components:
schemas:
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
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
project:
properties:
createdAt:
type: string
format: date-time
description: Timestamp when project was created
deadline:
type:
- string
- 'null'
format: date
description: Target completion date
description:
type:
- string
- 'null'
description: Detailed project description
id:
type: string
description: Unique project identifier
name:
type: string
description: Human-readable project name
priority:
enum:
- low
- medium
- high
- critical
type: string
status:
enum:
- active
- archived
- completed
- paused
type: string
updatedAt:
type: string
format: date-time
description: Timestamp of last modification
type: object
required:
- createdAt
- deadline
- description
- id
- name
- priority
- status
- updatedAt
projectCreatePayload:
properties:
deadline:
type:
- string
- 'null'
format: date
description: Target completion date
default:
description:
type:
- string
- 'null'
description: Detailed project description
default:
name:
type: string
description: Human-readable project name
priority:
enum:
- low
- medium
- high
- critical
type: string
status:
enum:
- active
- archived
- completed
- paused
type: string
type: object
required:
- name
projectFilter:
properties:
AND:
items:
"$ref": "#/components/schemas/projectFilter"
type: array
NOT:
"$ref": "#/components/schemas/projectFilter"
OR:
items:
"$ref": "#/components/schemas/projectFilter"
type: array
priority:
"$ref": "#/components/schemas/projectPriorityFilter"
status:
"$ref": "#/components/schemas/projectStatusFilter"
type: object
projectPage:
properties:
number:
type: integer
minimum: 1
size:
type: integer
minimum: 1
maximum: 100
type: object
projectPriorityFilter:
oneOf:
- enum:
- low
- medium
- high
- critical
type: string
- properties:
eq:
enum:
- low
- medium
- high
- critical
type: string
in:
items:
enum:
- low
- medium
- high
- critical
type: string
type: array
type: object
required:
- eq
- in
projectSort:
properties:
createdAt:
enum:
- asc
- desc
type: string
description: Timestamp when project was created
deadline:
enum:
- asc
- desc
type: string
description: Target completion date
updatedAt:
enum:
- asc
- desc
type: string
description: Timestamp of last modification
type: object
projectStatusFilter:
oneOf:
- enum:
- active
- archived
- completed
- paused
type: string
- properties:
eq:
enum:
- active
- archived
- completed
- paused
type: string
in:
items:
enum:
- active
- archived
- completed
- paused
type: string
type: array
type: object
required:
- eq
- in
projectUpdatePayload:
properties:
deadline:
type:
- string
- 'null'
format: date
description: Target completion date
description:
type:
- string
- 'null'
description: Detailed project description
name:
type: string
description: Human-readable project name
priority:
enum:
- low
- medium
- high
- critical
type: string
status:
enum:
- active
- archived
- completed
- paused
type: string
type: objectApiwork
json
{
"base_path": "/wise_tiger",
"enums": [
{
"deprecated": false,
"description": null,
"example": null,
"name": "error_layer",
"scope": null,
"values": [
"http",
"contract",
"domain"
]
},
{
"deprecated": false,
"description": null,
"example": null,
"name": "project_priority",
"scope": "project",
"values": [
"low",
"medium",
"high",
"critical"
]
},
{
"deprecated": false,
"description": null,
"example": null,
"name": "project_status",
"scope": "project",
"values": [
"active",
"archived",
"completed",
"paused"
]
},
{
"deprecated": false,
"description": null,
"example": null,
"name": "sort_direction",
"scope": null,
"values": [
"asc",
"desc"
]
}
],
"error_codes": [
{
"description": "Unprocessable Entity",
"name": "unprocessable_entity",
"status": 422
}
],
"fingerprint": "f585fb93bd68138a",
"info": {
"contact": null,
"description": "API for managing projects with I18n-powered documentation",
"license": null,
"servers": [],
"summary": null,
"terms_of_service": null,
"title": "Project Management API",
"version": "1.0.0"
},
"locales": [],
"resources": [
{
"actions": [
{
"name": "projects.index",
"deprecated": false,
"description": "Returns a paginated list of projects with optional filtering",
"method": "get",
"operation_id": null,
"path": "/projects",
"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": "project_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": "project_filter"
}
}
]
},
{
"name": "page",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "project_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": "project_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": "project_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": "projects",
"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": "project"
}
}
]
},
"description": null,
"no_content": false
},
"summary": "List all projects",
"tags": []
},
{
"name": "projects.show",
"deprecated": false,
"description": "Returns a single project by ID with all attributes",
"method": "get",
"operation_id": null,
"path": "/projects/: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": "project",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project"
}
]
},
"description": null,
"no_content": false
},
"summary": "Get project details",
"tags": []
},
{
"name": "projects.create",
"deprecated": false,
"description": "Creates a project and returns the created resource",
"method": "post",
"operation_id": null,
"path": "/projects",
"raises": [
"unprocessable_entity"
],
"request": {
"body": [
{
"name": "project",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_create_payload"
}
],
"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": "project",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project"
}
]
},
"description": null,
"no_content": false
},
"summary": "Create a new project",
"tags": []
},
{
"name": "projects.update",
"deprecated": false,
"description": "Updates an existing project with the provided attributes",
"method": "patch",
"operation_id": null,
"path": "/projects/:id",
"raises": [
"unprocessable_entity"
],
"request": {
"body": [
{
"name": "project",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_update_payload"
}
],
"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": "project",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project"
}
]
},
"description": null,
"no_content": false
},
"summary": "Update a project",
"tags": []
},
{
"name": "projects.destroy",
"deprecated": false,
"description": "Permanently removes a project",
"method": "delete",
"operation_id": null,
"path": "/projects/:id",
"raises": [],
"request": {
"body": [],
"description": null,
"query": []
},
"response": {
"body": null,
"description": null,
"no_content": true
},
"summary": "Delete a project",
"tags": []
}
],
"identifier": "projects",
"name": "projects",
"parent_identifiers": [],
"path": "projects",
"resources": [],
"scope": "project"
}
],
"types": [
{
"recursive": true,
"deprecated": false,
"description": null,
"example": null,
"name": "project_filter",
"scope": "project",
"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": "project_filter"
}
},
{
"name": "NOT",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "project_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": "project_filter"
}
},
{
"name": "priority",
"deprecated": false,
"description": "Project priority for resource allocation",
"nullable": false,
"optional": true,
"type": "reference",
"reference": "project_priority_filter"
},
{
"name": "status",
"deprecated": false,
"description": "Current project lifecycle status",
"nullable": false,
"optional": true,
"type": "reference",
"reference": "project_status_filter"
}
]
},
{
"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": "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": "project",
"scope": "project",
"type": "object",
"extends": [],
"shape": [
{
"name": "createdAt",
"deprecated": false,
"description": "Timestamp when project was created",
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
},
{
"name": "deadline",
"deprecated": false,
"description": "Target completion date",
"nullable": true,
"optional": false,
"type": "date",
"example": null
},
{
"name": "description",
"deprecated": false,
"description": "Detailed project description",
"nullable": true,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "id",
"deprecated": false,
"description": "Unique project identifier",
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "name",
"deprecated": false,
"description": "Human-readable project name",
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "priority",
"deprecated": false,
"description": "Project priority for resource allocation",
"nullable": false,
"optional": false,
"type": "string",
"enum": "project_priority",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "status",
"deprecated": false,
"description": "Current project lifecycle status",
"nullable": false,
"optional": false,
"type": "string",
"enum": "project_status",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "updatedAt",
"deprecated": false,
"description": "Timestamp of last modification",
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "project_create_payload",
"scope": "project",
"type": "object",
"extends": [],
"shape": [
{
"name": "deadline",
"deprecated": false,
"description": "Target completion date",
"nullable": true,
"optional": true,
"type": "date",
"default": null,
"example": null
},
{
"name": "description",
"deprecated": false,
"description": "Detailed project description",
"nullable": true,
"optional": true,
"type": "string",
"default": null,
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "name",
"deprecated": false,
"description": "Human-readable project name",
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "priority",
"deprecated": false,
"description": "Project priority for resource allocation",
"nullable": false,
"optional": true,
"type": "string",
"default": "medium",
"enum": "project_priority",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "status",
"deprecated": false,
"description": "Current project lifecycle status",
"nullable": false,
"optional": true,
"type": "string",
"default": "active",
"enum": "project_status",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "project_page",
"scope": "project",
"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": "project_priority_filter",
"scope": "project",
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_priority"
},
{
"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": "project_priority"
},
{
"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": "project_priority"
}
}
]
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "project_sort",
"scope": "project",
"type": "object",
"extends": [],
"shape": [
{
"name": "createdAt",
"deprecated": false,
"description": "Timestamp when project was created",
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
},
{
"name": "deadline",
"deprecated": false,
"description": "Target completion date",
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
},
{
"name": "updatedAt",
"deprecated": false,
"description": "Timestamp of last modification",
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "project_status_filter",
"scope": "project",
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_status"
},
{
"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": "project_status"
},
{
"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": "project_status"
}
}
]
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "project_update_payload",
"scope": "project",
"type": "object",
"extends": [],
"shape": [
{
"name": "deadline",
"deprecated": false,
"description": "Target completion date",
"nullable": true,
"optional": true,
"type": "date",
"example": null
},
{
"name": "description",
"deprecated": false,
"description": "Detailed project description",
"nullable": true,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "name",
"deprecated": false,
"description": "Human-readable project name",
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "priority",
"deprecated": false,
"description": "Project priority for resource allocation",
"nullable": false,
"optional": true,
"type": "string",
"enum": "project_priority",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "status",
"deprecated": false,
"description": "Current project lifecycle status",
"nullable": false,
"optional": true,
"type": "string",
"enum": "project_status",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"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"
}
]
}
]
}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 OffsetPagination {
current: number;
items: number;
next?: number | null;
prev?: number | null;
total: number;
}
export interface Error {
issues: ErrorIssue[];
layer: ErrorLayer;
}ts
export * from './project';ts
import type { SortDirection } from '../api';
export type ProjectPriority = 'low' | 'medium' | 'high' | 'critical';
export type ProjectStatus = 'active' | 'archived' | 'completed' | 'paused';
export interface ProjectFilter {
AND?: ProjectFilter[];
NOT?: ProjectFilter;
OR?: ProjectFilter[];
priority?: ProjectPriorityFilter;
status?: ProjectStatusFilter;
}
export interface Project {
createdAt: string;
deadline: string | null;
description: string | null;
id: string;
name: string;
priority: ProjectPriority;
status: ProjectStatus;
updatedAt: string;
}
export interface ProjectCreatePayload {
deadline?: string | null;
description?: string | null;
name: string;
priority?: ProjectPriority;
status?: ProjectStatus;
}
export interface ProjectPage {
number?: number;
size?: number;
}
export type ProjectPriorityFilter =
| ProjectPriority
| { eq?: ProjectPriority; in?: ProjectPriority[] };
export interface ProjectSort {
createdAt?: SortDirection;
deadline?: SortDirection;
updatedAt?: SortDirection;
}
export type ProjectStatusFilter =
| ProjectStatus
| { eq?: ProjectStatus; in?: ProjectStatus[] };
export interface ProjectUpdatePayload {
deadline?: string | null;
description?: string | null;
name?: string;
priority?: ProjectPriority;
status?: ProjectStatus;
}ts
export * from './projects';ts
import type { OffsetPagination } from '../api';
import type {
Project,
ProjectCreatePayload,
ProjectFilter,
ProjectPage,
ProjectSort,
ProjectUpdatePayload,
} from '../domains/project';
export type ProjectsIndexMethod = 'GET';
export type ProjectsIndexPath = '/projects';
export interface ProjectsIndexRequestQuery {
filter?: ProjectFilter | ProjectFilter[];
page?: ProjectPage;
sort?: ProjectSort | ProjectSort[];
}
export type ProjectsIndexResponseBody = {
meta?: Record<string, unknown>;
pagination: OffsetPagination;
projects: Project[];
};
export interface ProjectsIndexRequest {
query: ProjectsIndexRequestQuery;
}
export interface ProjectsIndexResponse {
body: ProjectsIndexResponseBody;
}
export interface ProjectsIndex {
method: ProjectsIndexMethod;
path: ProjectsIndexPath;
request: ProjectsIndexRequest;
response: ProjectsIndexResponse;
}
export type ProjectsShowMethod = 'GET';
export type ProjectsShowPath = '/projects/:id';
export interface ProjectsShowPathParams {
id: string;
}
export type ProjectsShowResponseBody = {
meta?: Record<string, unknown>;
project: Project;
};
export interface ProjectsShowResponse {
body: ProjectsShowResponseBody;
}
export interface ProjectsShow {
method: ProjectsShowMethod;
path: ProjectsShowPath;
pathParams: ProjectsShowPathParams;
response: ProjectsShowResponse;
}
export type ProjectsCreateMethod = 'POST';
export type ProjectsCreatePath = '/projects';
export interface ProjectsCreateRequestBody {
project: ProjectCreatePayload;
}
export type ProjectsCreateResponseBody = {
meta?: Record<string, unknown>;
project: Project;
};
export interface ProjectsCreateRequest {
body: ProjectsCreateRequestBody;
}
export interface ProjectsCreateResponse {
body: ProjectsCreateResponseBody;
}
export type ProjectsCreateErrors = 422;
export interface ProjectsCreate {
errors: ProjectsCreateErrors;
method: ProjectsCreateMethod;
path: ProjectsCreatePath;
request: ProjectsCreateRequest;
response: ProjectsCreateResponse;
}
export type ProjectsUpdateMethod = 'PATCH';
export type ProjectsUpdatePath = '/projects/:id';
export interface ProjectsUpdatePathParams {
id: string;
}
export interface ProjectsUpdateRequestBody {
project: ProjectUpdatePayload;
}
export type ProjectsUpdateResponseBody = {
meta?: Record<string, unknown>;
project: Project;
};
export interface ProjectsUpdateRequest {
body: ProjectsUpdateRequestBody;
}
export interface ProjectsUpdateResponse {
body: ProjectsUpdateResponseBody;
}
export type ProjectsUpdateErrors = 422;
export interface ProjectsUpdate {
errors: ProjectsUpdateErrors;
method: ProjectsUpdateMethod;
path: ProjectsUpdatePath;
pathParams: ProjectsUpdatePathParams;
request: ProjectsUpdateRequest;
response: ProjectsUpdateResponse;
}
export type ProjectsDestroyMethod = 'DELETE';
export type ProjectsDestroyPath = '/projects/:id';
export interface ProjectsDestroyPathParams {
id: string;
}
export interface ProjectsDestroy {
method: ProjectsDestroyMethod;
path: ProjectsDestroyPath;
pathParams: ProjectsDestroyPathParams;
}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 OffsetPaginationSchema = z.object({
current: z.number().int(),
items: z.number().int(),
next: z.number().int().nullable().optional(),
prev: z.number().int().nullable().optional(),
total: z.number().int(),
});
export const ErrorSchema = z.object({
issues: z.array(ErrorIssueSchema),
layer: ErrorLayerSchema,
});
export type ErrorLayer = 'contract' | 'domain' | 'http';
export type SortDirection = 'asc' | 'desc';
export interface ErrorIssue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string | number[];
pointer: string;
}
export interface OffsetPagination {
current: number;
items: number;
next?: number | null;
prev?: number | null;
total: number;
}
export interface Error {
issues: ErrorIssue[];
layer: ErrorLayer;
}ts
export * from './project';ts
import type { SortDirection } from '../api';
import * as z from 'zod';
import { SortDirectionSchema } from '../api';
export const ProjectPrioritySchema = z.enum([
'critical',
'high',
'low',
'medium',
]);
export const ProjectStatusSchema = z.enum([
'active',
'archived',
'completed',
'paused',
]);
export const ProjectFilterSchema: z.ZodType<ProjectFilter> = z.lazy(() =>
z.object({
AND: z.array(ProjectFilterSchema).optional(),
NOT: ProjectFilterSchema.optional(),
OR: z.array(ProjectFilterSchema).optional(),
priority: ProjectPriorityFilterSchema.optional(),
status: ProjectStatusFilterSchema.optional(),
}),
);
export const ProjectSchema = z.object({
createdAt: z.iso.datetime(),
deadline: z.iso.date().nullable(),
description: z.string().nullable(),
id: z.string(),
name: z.string(),
priority: ProjectPrioritySchema,
status: ProjectStatusSchema,
updatedAt: z.iso.datetime(),
});
export const ProjectCreatePayloadSchema = z.object({
deadline: z.iso.date().nullable().default(null),
description: z.string().nullable().default(null),
name: z.string(),
priority: ProjectPrioritySchema.default('medium'),
status: ProjectStatusSchema.default('active'),
});
export const ProjectPageSchema = z.object({
number: z.number().int().min(1).optional(),
size: z.number().int().min(1).max(100).optional(),
});
export const ProjectPriorityFilterSchema = z.union([
ProjectPrioritySchema,
z
.object({ eq: ProjectPrioritySchema, in: z.array(ProjectPrioritySchema) })
.partial(),
]);
export const ProjectSortSchema = z.object({
createdAt: SortDirectionSchema.optional(),
deadline: SortDirectionSchema.optional(),
updatedAt: SortDirectionSchema.optional(),
});
export const ProjectStatusFilterSchema = z.union([
ProjectStatusSchema,
z
.object({ eq: ProjectStatusSchema, in: z.array(ProjectStatusSchema) })
.partial(),
]);
export const ProjectUpdatePayloadSchema = z.object({
deadline: z.iso.date().nullable().optional(),
description: z.string().nullable().optional(),
name: z.string().optional(),
priority: ProjectPrioritySchema.optional(),
status: ProjectStatusSchema.optional(),
});
export type ProjectPriority = 'critical' | 'high' | 'low' | 'medium';
export type ProjectStatus = 'active' | 'archived' | 'completed' | 'paused';
export interface ProjectFilter {
AND?: ProjectFilter[];
NOT?: ProjectFilter;
OR?: ProjectFilter[];
priority?: ProjectPriorityFilter;
status?: ProjectStatusFilter;
}
export interface Project {
createdAt: string;
deadline: string | null;
description: string | null;
id: string;
name: string;
priority: ProjectPriority;
status: ProjectStatus;
updatedAt: string;
}
export interface ProjectCreatePayload {
deadline?: string | null;
description?: string | null;
name: string;
priority?: ProjectPriority;
status?: ProjectStatus;
}
export interface ProjectPage {
number?: number;
size?: number;
}
export type ProjectPriorityFilter =
| ProjectPriority
| { eq?: ProjectPriority; in?: ProjectPriority[] };
export interface ProjectSort {
createdAt?: SortDirection;
deadline?: SortDirection;
updatedAt?: SortDirection;
}
export type ProjectStatusFilter =
| ProjectStatus
| { eq?: ProjectStatus; in?: ProjectStatus[] };
export interface ProjectUpdatePayload {
deadline?: string | null;
description?: string | null;
name?: string;
priority?: ProjectPriority;
status?: ProjectStatus;
}ts
export * from './projects';ts
import type { OffsetPagination } from '../api';
import type {
Project,
ProjectCreatePayload,
ProjectFilter,
ProjectPage,
ProjectSort,
ProjectUpdatePayload,
} from '../domains/project';
import * as z from 'zod';
import { OffsetPaginationSchema } from '../api';
import {
ProjectCreatePayloadSchema,
ProjectFilterSchema,
ProjectPageSchema,
ProjectSchema,
ProjectSortSchema,
ProjectUpdatePayloadSchema,
} from '../domains/project';
export const ProjectsIndexRequestQuerySchema = z.object({
filter: z
.union([ProjectFilterSchema, z.array(ProjectFilterSchema)])
.optional(),
page: ProjectPageSchema.optional(),
sort: z.union([ProjectSortSchema, z.array(ProjectSortSchema)]).optional(),
});
export const ProjectsIndexResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
pagination: OffsetPaginationSchema,
projects: z.array(ProjectSchema),
});
export const ProjectsShowPathParamsSchema = z.object({ id: z.string() });
export const ProjectsShowResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
project: ProjectSchema,
});
export const ProjectsCreateRequestBodySchema = z.object({
project: ProjectCreatePayloadSchema,
});
export const ProjectsCreateResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
project: ProjectSchema,
});
export const ProjectsUpdatePathParamsSchema = z.object({ id: z.string() });
export const ProjectsUpdateRequestBodySchema = z.object({
project: ProjectUpdatePayloadSchema,
});
export const ProjectsUpdateResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
project: ProjectSchema,
});
export const ProjectsDestroyPathParamsSchema = z.object({ id: z.string() });
export type ProjectsIndexMethod = 'GET';
export type ProjectsIndexPath = '/projects';
export interface ProjectsIndexRequestQuery {
filter?: ProjectFilter | ProjectFilter[];
page?: ProjectPage;
sort?: ProjectSort | ProjectSort[];
}
export type ProjectsIndexResponseBody = {
meta?: Record<string, unknown>;
pagination: OffsetPagination;
projects: Project[];
};
export interface ProjectsIndexRequest {
query: ProjectsIndexRequestQuery;
}
export interface ProjectsIndexResponse {
body: ProjectsIndexResponseBody;
}
export interface ProjectsIndex {
method: ProjectsIndexMethod;
path: ProjectsIndexPath;
request: ProjectsIndexRequest;
response: ProjectsIndexResponse;
}
export type ProjectsShowMethod = 'GET';
export type ProjectsShowPath = '/projects/:id';
export interface ProjectsShowPathParams {
id: string;
}
export type ProjectsShowResponseBody = {
meta?: Record<string, unknown>;
project: Project;
};
export interface ProjectsShowResponse {
body: ProjectsShowResponseBody;
}
export interface ProjectsShow {
method: ProjectsShowMethod;
path: ProjectsShowPath;
pathParams: ProjectsShowPathParams;
response: ProjectsShowResponse;
}
export type ProjectsCreateMethod = 'POST';
export type ProjectsCreatePath = '/projects';
export interface ProjectsCreateRequestBody {
project: ProjectCreatePayload;
}
export type ProjectsCreateResponseBody = {
meta?: Record<string, unknown>;
project: Project;
};
export interface ProjectsCreateRequest {
body: ProjectsCreateRequestBody;
}
export interface ProjectsCreateResponse {
body: ProjectsCreateResponseBody;
}
export type ProjectsCreateErrors = 422;
export interface ProjectsCreate {
errors: ProjectsCreateErrors;
method: ProjectsCreateMethod;
path: ProjectsCreatePath;
request: ProjectsCreateRequest;
response: ProjectsCreateResponse;
}
export type ProjectsUpdateMethod = 'PATCH';
export type ProjectsUpdatePath = '/projects/:id';
export interface ProjectsUpdatePathParams {
id: string;
}
export interface ProjectsUpdateRequestBody {
project: ProjectUpdatePayload;
}
export type ProjectsUpdateResponseBody = {
meta?: Record<string, unknown>;
project: Project;
};
export interface ProjectsUpdateRequest {
body: ProjectsUpdateRequestBody;
}
export interface ProjectsUpdateResponse {
body: ProjectsUpdateResponseBody;
}
export type ProjectsUpdateErrors = 422;
export interface ProjectsUpdate {
errors: ProjectsUpdateErrors;
method: ProjectsUpdateMethod;
path: ProjectsUpdatePath;
pathParams: ProjectsUpdatePathParams;
request: ProjectsUpdateRequest;
response: ProjectsUpdateResponse;
}
export type ProjectsDestroyMethod = 'DELETE';
export type ProjectsDestroyPath = '/projects/:id';
export interface ProjectsDestroyPathParams {
id: string;
}
export interface ProjectsDestroy {
method: ProjectsDestroyMethod;
path: ProjectsDestroyPath;
pathParams: ProjectsDestroyPathParams;
}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 OffsetPaginationSchema = z.object({
current: z.number().int(),
items: z.number().int(),
next: z.number().int().nullable().optional(),
prev: z.number().int().nullable().optional(),
total: z.number().int(),
});
export const ErrorSchema = z.object({
issues: z.array(ErrorIssueSchema),
layer: ErrorLayerSchema,
});
export type ErrorLayer = 'contract' | 'domain' | 'http';
export type SortDirection = 'asc' | 'desc';
export interface ErrorIssue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string | number[];
pointer: string;
}
export interface OffsetPagination {
current: number;
items: number;
next?: number | null;
prev?: number | null;
total: number;
}
export interface Error {
issues: ErrorIssue[];
layer: ErrorLayer;
}ts
import type { ProjectsOperationTree } from './endpoints';
import { createClientFactory } from 'sorbus';
import { contract } from './contract';
export interface Client {
projects: ProjectsOperationTree;
}
export const createClient = createClientFactory<Client>(contract);ts
import { ErrorSchema } from './api';
import { projects } from './endpoints';
export const contract = {
endpoints: {
projects,
},
error: ErrorSchema,
} as const;ts
export * from './project';ts
import type { SortDirection } from '../api';
import * as z from 'zod';
import { SortDirectionSchema } from '../api';
export const ProjectPrioritySchema = z.enum([
'critical',
'high',
'low',
'medium',
]);
export const ProjectStatusSchema = z.enum([
'active',
'archived',
'completed',
'paused',
]);
export const ProjectFilterSchema: z.ZodType<ProjectFilter> = z.lazy(() =>
z.object({
AND: z.array(ProjectFilterSchema).optional(),
NOT: ProjectFilterSchema.optional(),
OR: z.array(ProjectFilterSchema).optional(),
priority: ProjectPriorityFilterSchema.optional(),
status: ProjectStatusFilterSchema.optional(),
}),
);
export const ProjectSchema = z.object({
createdAt: z.iso.datetime(),
deadline: z.iso.date().nullable(),
description: z.string().nullable(),
id: z.string(),
name: z.string(),
priority: ProjectPrioritySchema,
status: ProjectStatusSchema,
updatedAt: z.iso.datetime(),
});
export const ProjectCreatePayloadSchema = z.object({
deadline: z.iso.date().nullable().default(null),
description: z.string().nullable().default(null),
name: z.string(),
priority: ProjectPrioritySchema.default('medium'),
status: ProjectStatusSchema.default('active'),
});
export const ProjectPageSchema = z.object({
number: z.number().int().min(1).optional(),
size: z.number().int().min(1).max(100).optional(),
});
export const ProjectPriorityFilterSchema = z.union([
ProjectPrioritySchema,
z
.object({ eq: ProjectPrioritySchema, in: z.array(ProjectPrioritySchema) })
.partial(),
]);
export const ProjectSortSchema = z.object({
createdAt: SortDirectionSchema.optional(),
deadline: SortDirectionSchema.optional(),
updatedAt: SortDirectionSchema.optional(),
});
export const ProjectStatusFilterSchema = z.union([
ProjectStatusSchema,
z
.object({ eq: ProjectStatusSchema, in: z.array(ProjectStatusSchema) })
.partial(),
]);
export const ProjectUpdatePayloadSchema = z.object({
deadline: z.iso.date().nullable().optional(),
description: z.string().nullable().optional(),
name: z.string().optional(),
priority: ProjectPrioritySchema.optional(),
status: ProjectStatusSchema.optional(),
});
export type ProjectPriority = 'critical' | 'high' | 'low' | 'medium';
export type ProjectStatus = 'active' | 'archived' | 'completed' | 'paused';
export interface ProjectFilter {
AND?: ProjectFilter[];
NOT?: ProjectFilter;
OR?: ProjectFilter[];
priority?: ProjectPriorityFilter;
status?: ProjectStatusFilter;
}
export interface Project {
createdAt: string;
deadline: string | null;
description: string | null;
id: string;
name: string;
priority: ProjectPriority;
status: ProjectStatus;
updatedAt: string;
}
export interface ProjectCreatePayload {
deadline?: string | null;
description?: string | null;
name: string;
priority?: ProjectPriority;
status?: ProjectStatus;
}
export interface ProjectPage {
number?: number;
size?: number;
}
export type ProjectPriorityFilter =
| ProjectPriority
| { eq?: ProjectPriority; in?: ProjectPriority[] };
export interface ProjectSort {
createdAt?: SortDirection;
deadline?: SortDirection;
updatedAt?: SortDirection;
}
export type ProjectStatusFilter =
| ProjectStatus
| { eq?: ProjectStatus; in?: ProjectStatus[] };
export interface ProjectUpdatePayload {
deadline?: string | null;
description?: string | null;
name?: string;
priority?: ProjectPriority;
status?: ProjectStatus;
}ts
export * from './projects';ts
import type { Operation } from 'sorbus';
import type { OffsetPagination } from '../api';
import type {
Project,
ProjectCreatePayload,
ProjectFilter,
ProjectPage,
ProjectSort,
ProjectUpdatePayload,
} from '../domains/project';
import * as z from 'zod';
import { OffsetPaginationSchema } from '../api';
import {
ProjectCreatePayloadSchema,
ProjectFilterSchema,
ProjectPageSchema,
ProjectSchema,
ProjectSortSchema,
ProjectUpdatePayloadSchema,
} from '../domains/project';
export const ProjectsIndexRequestQuerySchema = z.object({
filter: z
.union([ProjectFilterSchema, z.array(ProjectFilterSchema)])
.optional(),
page: ProjectPageSchema.optional(),
sort: z.union([ProjectSortSchema, z.array(ProjectSortSchema)]).optional(),
});
export const ProjectsIndexResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
pagination: OffsetPaginationSchema,
projects: z.array(ProjectSchema),
});
export const ProjectsShowPathParamsSchema = z.object({ id: z.string() });
export const ProjectsShowResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
project: ProjectSchema,
});
export const ProjectsCreateRequestBodySchema = z.object({
project: ProjectCreatePayloadSchema,
});
export const ProjectsCreateResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
project: ProjectSchema,
});
export const ProjectsUpdatePathParamsSchema = z.object({ id: z.string() });
export const ProjectsUpdateRequestBodySchema = z.object({
project: ProjectUpdatePayloadSchema,
});
export const ProjectsUpdateResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
project: ProjectSchema,
});
export const ProjectsDestroyPathParamsSchema = z.object({ id: z.string() });
export type ProjectsIndexMethod = 'GET';
export type ProjectsIndexPath = '/projects';
export interface ProjectsIndexRequestQuery {
filter?: ProjectFilter | ProjectFilter[];
page?: ProjectPage;
sort?: ProjectSort | ProjectSort[];
}
export type ProjectsIndexResponseBody = {
meta?: Record<string, unknown>;
pagination: OffsetPagination;
projects: Project[];
};
export interface ProjectsIndexRequest {
query: ProjectsIndexRequestQuery;
}
export interface ProjectsIndexResponse {
body: ProjectsIndexResponseBody;
}
export interface ProjectsIndex {
method: ProjectsIndexMethod;
path: ProjectsIndexPath;
request: ProjectsIndexRequest;
response: ProjectsIndexResponse;
}
export type ProjectsShowMethod = 'GET';
export type ProjectsShowPath = '/projects/:id';
export interface ProjectsShowPathParams {
id: string;
}
export type ProjectsShowResponseBody = {
meta?: Record<string, unknown>;
project: Project;
};
export interface ProjectsShowResponse {
body: ProjectsShowResponseBody;
}
export interface ProjectsShow {
method: ProjectsShowMethod;
path: ProjectsShowPath;
pathParams: ProjectsShowPathParams;
response: ProjectsShowResponse;
}
export type ProjectsCreateMethod = 'POST';
export type ProjectsCreatePath = '/projects';
export interface ProjectsCreateRequestBody {
project: ProjectCreatePayload;
}
export type ProjectsCreateResponseBody = {
meta?: Record<string, unknown>;
project: Project;
};
export interface ProjectsCreateRequest {
body: ProjectsCreateRequestBody;
}
export interface ProjectsCreateResponse {
body: ProjectsCreateResponseBody;
}
export type ProjectsCreateErrors = 422;
export interface ProjectsCreate {
errors: ProjectsCreateErrors;
method: ProjectsCreateMethod;
path: ProjectsCreatePath;
request: ProjectsCreateRequest;
response: ProjectsCreateResponse;
}
export type ProjectsUpdateMethod = 'PATCH';
export type ProjectsUpdatePath = '/projects/:id';
export interface ProjectsUpdatePathParams {
id: string;
}
export interface ProjectsUpdateRequestBody {
project: ProjectUpdatePayload;
}
export type ProjectsUpdateResponseBody = {
meta?: Record<string, unknown>;
project: Project;
};
export interface ProjectsUpdateRequest {
body: ProjectsUpdateRequestBody;
}
export interface ProjectsUpdateResponse {
body: ProjectsUpdateResponseBody;
}
export type ProjectsUpdateErrors = 422;
export interface ProjectsUpdate {
errors: ProjectsUpdateErrors;
method: ProjectsUpdateMethod;
path: ProjectsUpdatePath;
pathParams: ProjectsUpdatePathParams;
request: ProjectsUpdateRequest;
response: ProjectsUpdateResponse;
}
export type ProjectsDestroyMethod = 'DELETE';
export type ProjectsDestroyPath = '/projects/:id';
export interface ProjectsDestroyPathParams {
id: string;
}
export interface ProjectsDestroy {
method: ProjectsDestroyMethod;
path: ProjectsDestroyPath;
pathParams: ProjectsDestroyPathParams;
}
export const projects = {
create: {
errors: [422],
method: 'POST',
path: '/projects',
request: {
body: ProjectsCreateRequestBodySchema,
},
response: {
body: ProjectsCreateResponseBodySchema,
},
},
destroy: {
method: 'DELETE',
path: '/projects/:id',
pathParams: ProjectsDestroyPathParamsSchema,
},
index: {
method: 'GET',
path: '/projects',
request: {
query: ProjectsIndexRequestQuerySchema,
},
response: {
body: ProjectsIndexResponseBodySchema,
},
},
show: {
method: 'GET',
path: '/projects/:id',
pathParams: ProjectsShowPathParamsSchema,
response: {
body: ProjectsShowResponseBodySchema,
},
},
update: {
errors: [422],
method: 'PATCH',
path: '/projects/:id',
pathParams: ProjectsUpdatePathParamsSchema,
request: {
body: ProjectsUpdateRequestBodySchema,
},
response: {
body: ProjectsUpdateResponseBodySchema,
},
},
} as const;
export interface ProjectsOperationTree {
create: Operation<ProjectsCreate>;
destroy: Operation<ProjectsDestroy>;
index: Operation<ProjectsIndex>;
show: Operation<ProjectsShow>;
update: Operation<ProjectsUpdate>;
}