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 :typescript
export :zod
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": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-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": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-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": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-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": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
}
}Generated Output
Introspection
json
{
"base_path": "/wise_tiger",
"enums": {
"layer": {
"deprecated": false,
"description": null,
"example": null,
"values": [
"http",
"contract",
"domain"
]
},
"project_priority": {
"deprecated": false,
"description": null,
"example": null,
"values": [
"low",
"medium",
"high",
"critical"
]
},
"project_status": {
"deprecated": false,
"description": null,
"example": null,
"values": [
"active",
"archived",
"completed",
"paused"
]
},
"sort_direction": {
"deprecated": false,
"description": null,
"example": null,
"values": [
"asc",
"desc"
]
}
},
"error_codes": {
"unprocessable_entity": {
"description": "Unprocessable Entity",
"status": 422
}
},
"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"
},
"resources": {
"projects": {
"actions": {
"index": {
"deprecated": false,
"description": "Returns a paginated list of projects with optional filtering",
"method": "get",
"operation_id": null,
"path": "/projects",
"raises": [],
"request": {
"body": {},
"query": {
"filter": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_filter"
},
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "project_filter"
},
"shape": {}
}
]
},
"page": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "project_page"
},
"sort": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_sort"
},
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "project_sort"
},
"shape": {}
}
]
}
}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "project_index_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": "List all projects",
"tags": []
},
"show": {
"deprecated": false,
"description": "Returns a single project by ID with all attributes",
"method": "get",
"operation_id": null,
"path": "/projects/:id",
"raises": [],
"request": {
"body": {},
"query": {}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "project_show_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": "Get project details",
"tags": []
},
"create": {
"deprecated": false,
"description": "Creates a project and returns the created resource",
"method": "post",
"operation_id": null,
"path": "/projects",
"raises": [
"unprocessable_entity"
],
"request": {
"body": {
"project": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_create_payload"
}
},
"query": {}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "project_create_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": "Create a new project",
"tags": []
},
"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": {
"project": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_update_payload"
}
},
"query": {}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "project_update_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": "Update a project",
"tags": []
},
"destroy": {
"deprecated": false,
"description": "Permanently removes a project",
"method": "delete",
"operation_id": null,
"path": "/projects/:id",
"raises": [],
"request": {
"body": {},
"query": {}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": null
},
"no_content": true
},
"summary": "Delete a project",
"tags": []
}
},
"identifier": "projects",
"parent_identifiers": [],
"path": "projects",
"resources": {}
}
},
"types": {
"error": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"issues": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "issue"
},
"shape": {}
},
"layer": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "layer"
}
},
"type": "object",
"variants": []
},
"error_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [
"error"
],
"shape": {},
"type": "object",
"variants": []
},
"issue": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"code": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"detail": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "object",
"partial": false,
"shape": {}
},
"path": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shape": {}
},
"pointer": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"offset_pagination": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"current": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"items": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"next": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"prev": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "integer",
"format": null,
"max": null,
"min": null
},
"total": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "integer",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"project": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"created_at": {
"default": null,
"deprecated": false,
"description": "Timestamp when project was created",
"example": null,
"nullable": false,
"optional": false,
"type": "datetime"
},
"deadline": {
"default": null,
"deprecated": false,
"description": "Target completion date",
"example": null,
"nullable": true,
"optional": false,
"type": "date"
},
"description": {
"default": null,
"deprecated": false,
"description": "Detailed project description",
"example": null,
"nullable": true,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"id": {
"default": null,
"deprecated": false,
"description": "Unique project identifier",
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"name": {
"default": null,
"deprecated": false,
"description": "Human-readable project name",
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"priority": {
"default": null,
"deprecated": false,
"description": "Project priority for resource allocation",
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"enum": "project_priority",
"format": null,
"max": null,
"min": null
},
"status": {
"default": null,
"deprecated": false,
"description": "Current project lifecycle status",
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"enum": "project_status",
"format": null,
"max": null,
"min": null
},
"updated_at": {
"default": null,
"deprecated": false,
"description": "Timestamp of last modification",
"example": null,
"nullable": false,
"optional": false,
"type": "datetime"
}
},
"type": "object",
"variants": []
},
"project_create_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"deadline": {
"default": null,
"deprecated": false,
"description": "Target completion date",
"example": null,
"nullable": true,
"optional": true,
"type": "date"
},
"description": {
"default": null,
"deprecated": false,
"description": "Detailed project description",
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"name": {
"default": null,
"deprecated": false,
"description": "Human-readable project name",
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"priority": {
"default": null,
"deprecated": false,
"description": "Project priority for resource allocation",
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"enum": "project_priority",
"format": null,
"max": null,
"min": null
},
"status": {
"default": null,
"deprecated": false,
"description": "Current project lifecycle status",
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"enum": "project_status",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"project_create_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
},
"project": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project"
}
},
"type": "object",
"variants": []
},
"project_filter": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"AND": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "project_filter"
},
"shape": {}
},
"NOT": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "project_filter"
},
"OR": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "project_filter"
},
"shape": {}
},
"priority": {
"default": null,
"deprecated": false,
"description": "Project priority for resource allocation",
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "project_priority_filter"
},
"status": {
"default": null,
"deprecated": false,
"description": "Current project lifecycle status",
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "project_status_filter"
}
},
"type": "object",
"variants": []
},
"project_index_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"pagination": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "offset_pagination"
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
},
"projects": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "project"
},
"shape": {}
}
},
"type": "object",
"variants": []
},
"project_page": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"number": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "integer",
"format": null,
"max": null,
"min": 1
},
"size": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "integer",
"format": null,
"max": 100,
"min": 1
}
},
"type": "object",
"variants": []
},
"project_priority_filter": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {},
"type": "union",
"variants": [
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_priority"
},
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "object",
"partial": true,
"shape": {
"eq": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_priority"
},
"in": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "project_priority"
},
"shape": {}
}
}
}
]
},
"project_show_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
},
"project": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project"
}
},
"type": "object",
"variants": []
},
"project_sort": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"created_at": {
"default": null,
"deprecated": false,
"description": "Timestamp when project was created",
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
},
"deadline": {
"default": null,
"deprecated": false,
"description": "Target completion date",
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
},
"updated_at": {
"default": null,
"deprecated": false,
"description": "Timestamp of last modification",
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
}
},
"type": "object",
"variants": []
},
"project_status_filter": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {},
"type": "union",
"variants": [
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_status"
},
{
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "object",
"partial": true,
"shape": {
"eq": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project_status"
},
"in": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "project_status"
},
"shape": {}
}
}
}
]
},
"project_update_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"deadline": {
"default": null,
"deprecated": false,
"description": "Target completion date",
"example": null,
"nullable": true,
"optional": true,
"type": "date"
},
"description": {
"default": null,
"deprecated": false,
"description": "Detailed project description",
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"name": {
"default": null,
"deprecated": false,
"description": "Human-readable project name",
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"priority": {
"default": null,
"deprecated": false,
"description": "Project priority for resource allocation",
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"enum": "project_priority",
"format": null,
"max": null,
"min": null
},
"status": {
"default": null,
"deprecated": false,
"description": "Current project lifecycle status",
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"enum": "project_status",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"project_update_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
},
"project": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "project"
}
},
"type": "object",
"variants": []
},
"string_filter": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"contains": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"ends_with": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"eq": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"in": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shape": {}
},
"starts_with": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
}
}
}TypeScript
ts
export interface Error {
issues: Issue[];
layer: Layer;
}
export type ErrorResponseBody = Error;
export interface Issue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string[];
pointer: string;
}
export type Layer = 'contract' | 'domain' | 'http';
export interface OffsetPagination {
current: number;
items: number;
next?: null | number;
prev?: null | number;
total: number;
}
export interface Project {
/** Timestamp when project was created */
createdAt: string;
/** Target completion date */
deadline: null | string;
/** Detailed project description */
description: null | string;
/** Unique project identifier */
id: string;
/** Human-readable project name */
name: string;
/** Project priority for resource allocation */
priority: ProjectPriority;
/** Current project lifecycle status */
status: ProjectStatus;
/** Timestamp of last modification */
updatedAt: string;
}
export interface ProjectCreatePayload {
/** Target completion date */
deadline?: null | string;
/** Detailed project description */
description?: null | string;
/** Human-readable project name */
name: string;
/** Project priority for resource allocation */
priority?: ProjectPriority;
/** Current project lifecycle status */
status?: ProjectStatus;
}
export interface ProjectCreateSuccessResponseBody {
meta?: Record<string, unknown>;
project: Project;
}
export interface ProjectFilter {
AND?: ProjectFilter[];
NOT?: ProjectFilter;
OR?: ProjectFilter[];
/** Project priority for resource allocation */
priority?: ProjectPriorityFilter;
/** Current project lifecycle status */
status?: ProjectStatusFilter;
}
export interface ProjectIndexSuccessResponseBody {
meta?: Record<string, unknown>;
pagination: OffsetPagination;
projects: Project[];
}
export interface ProjectPage {
number?: number;
size?: number;
}
export type ProjectPriority = 'critical' | 'high' | 'low' | 'medium';
export type ProjectPriorityFilter = ProjectPriority | { eq?: ProjectPriority; in?: ProjectPriority[] };
export interface ProjectShowSuccessResponseBody {
meta?: Record<string, unknown>;
project: Project;
}
export interface ProjectSort {
/** Timestamp when project was created */
createdAt?: SortDirection;
/** Target completion date */
deadline?: SortDirection;
/** Timestamp of last modification */
updatedAt?: SortDirection;
}
export type ProjectStatus = 'active' | 'archived' | 'completed' | 'paused';
export type ProjectStatusFilter = ProjectStatus | { eq?: ProjectStatus; in?: ProjectStatus[] };
export interface ProjectUpdatePayload {
/** Target completion date */
deadline?: null | string;
/** Detailed project description */
description?: null | string;
/** Human-readable project name */
name?: string;
/** Project priority for resource allocation */
priority?: ProjectPriority;
/** Current project lifecycle status */
status?: ProjectStatus;
}
export interface ProjectUpdateSuccessResponseBody {
meta?: Record<string, unknown>;
project: Project;
}
export interface ProjectsCreateRequest {
body: ProjectsCreateRequestBody;
}
export interface ProjectsCreateRequestBody {
project: ProjectCreatePayload;
}
export interface ProjectsCreateResponse {
body: ProjectsCreateResponseBody;
}
export type ProjectsCreateResponseBody = ErrorResponseBody | ProjectCreateSuccessResponseBody;
export type ProjectsDestroyResponse = never;
export interface ProjectsIndexRequest {
query: ProjectsIndexRequestQuery;
}
export interface ProjectsIndexRequestQuery {
filter?: ProjectFilter | ProjectFilter[];
page?: ProjectPage;
sort?: ProjectSort | ProjectSort[];
}
export interface ProjectsIndexResponse {
body: ProjectsIndexResponseBody;
}
export type ProjectsIndexResponseBody = ErrorResponseBody | ProjectIndexSuccessResponseBody;
export interface ProjectsShowResponse {
body: ProjectsShowResponseBody;
}
export type ProjectsShowResponseBody = ErrorResponseBody | ProjectShowSuccessResponseBody;
export interface ProjectsUpdateRequest {
body: ProjectsUpdateRequestBody;
}
export interface ProjectsUpdateRequestBody {
project: ProjectUpdatePayload;
}
export interface ProjectsUpdateResponse {
body: ProjectsUpdateResponseBody;
}
export type ProjectsUpdateResponseBody = ErrorResponseBody | ProjectUpdateSuccessResponseBody;
export type SortDirection = 'asc' | 'desc';Zod
ts
import { z } from 'zod';
export const LayerSchema = z.enum(['contract', 'domain', 'http']);
export const ProjectPrioritySchema = z.enum(['critical', 'high', 'low', 'medium']);
export const ProjectStatusSchema = z.enum(['active', 'archived', 'completed', 'paused']);
export const SortDirectionSchema = z.enum(['asc', 'desc']);
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 IssueSchema = z.object({
code: z.string(),
detail: z.string(),
meta: z.record(z.string(), z.unknown()),
path: z.array(z.string()),
pointer: z.string()
});
export const OffsetPaginationSchema = z.object({
current: z.number().int(),
items: z.number().int(),
next: z.number().int().nullable().optional(),
prev: z.number().int().nullable().optional(),
total: z.number().int()
});
export const 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().optional(),
description: z.string().nullable().optional(),
name: z.string(),
priority: ProjectPrioritySchema.optional(),
status: ProjectStatusSchema.optional()
});
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 const ErrorSchema = z.object({
issues: z.array(IssueSchema),
layer: LayerSchema
});
export const ProjectCreateSuccessResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
project: ProjectSchema
});
export const ProjectIndexSuccessResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
pagination: OffsetPaginationSchema,
projects: z.array(ProjectSchema)
});
export const ProjectShowSuccessResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
project: ProjectSchema
});
export const ProjectUpdateSuccessResponseBodySchema = z.object({
meta: z.record(z.string(), z.unknown()).optional(),
project: ProjectSchema
});
export const ErrorResponseBodySchema = ErrorSchema;
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 ProjectsIndexRequestSchema = z.object({
query: ProjectsIndexRequestQuerySchema
});
export const ProjectsIndexResponseBodySchema = z.union([ProjectIndexSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const ProjectsIndexResponseSchema = z.object({
body: ProjectsIndexResponseBodySchema
});
export const ProjectsShowResponseBodySchema = z.union([ProjectShowSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const ProjectsShowResponseSchema = z.object({
body: ProjectsShowResponseBodySchema
});
export const ProjectsCreateRequestBodySchema = z.object({
project: ProjectCreatePayloadSchema
});
export const ProjectsCreateRequestSchema = z.object({
body: ProjectsCreateRequestBodySchema
});
export const ProjectsCreateResponseBodySchema = z.union([ProjectCreateSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const ProjectsCreateResponseSchema = z.object({
body: ProjectsCreateResponseBodySchema
});
export const ProjectsUpdateRequestBodySchema = z.object({
project: ProjectUpdatePayloadSchema
});
export const ProjectsUpdateRequestSchema = z.object({
body: ProjectsUpdateRequestBodySchema
});
export const ProjectsUpdateResponseBodySchema = z.union([ProjectUpdateSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const ProjectsUpdateResponseSchema = z.object({
body: ProjectsUpdateResponseBodySchema
});
export const ProjectsDestroyResponseSchema = z.never();
export interface Error {
issues: Issue[];
layer: Layer;
}
export type ErrorResponseBody = Error;
export interface Issue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string[];
pointer: string;
}
export type Layer = 'contract' | 'domain' | 'http';
export interface OffsetPagination {
current: number;
items: number;
next?: null | number;
prev?: null | number;
total: number;
}
export interface Project {
/** Timestamp when project was created */
createdAt: string;
/** Target completion date */
deadline: null | string;
/** Detailed project description */
description: null | string;
/** Unique project identifier */
id: string;
/** Human-readable project name */
name: string;
/** Project priority for resource allocation */
priority: ProjectPriority;
/** Current project lifecycle status */
status: ProjectStatus;
/** Timestamp of last modification */
updatedAt: string;
}
export interface ProjectCreatePayload {
/** Target completion date */
deadline?: null | string;
/** Detailed project description */
description?: null | string;
/** Human-readable project name */
name: string;
/** Project priority for resource allocation */
priority?: ProjectPriority;
/** Current project lifecycle status */
status?: ProjectStatus;
}
export interface ProjectCreateSuccessResponseBody {
meta?: Record<string, unknown>;
project: Project;
}
export interface ProjectFilter {
AND?: ProjectFilter[];
NOT?: ProjectFilter;
OR?: ProjectFilter[];
/** Project priority for resource allocation */
priority?: ProjectPriorityFilter;
/** Current project lifecycle status */
status?: ProjectStatusFilter;
}
export interface ProjectIndexSuccessResponseBody {
meta?: Record<string, unknown>;
pagination: OffsetPagination;
projects: Project[];
}
export interface ProjectPage {
number?: number;
size?: number;
}
export type ProjectPriority = 'critical' | 'high' | 'low' | 'medium';
export type ProjectPriorityFilter = ProjectPriority | { eq?: ProjectPriority; in?: ProjectPriority[] };
export interface ProjectShowSuccessResponseBody {
meta?: Record<string, unknown>;
project: Project;
}
export interface ProjectSort {
/** Timestamp when project was created */
createdAt?: SortDirection;
/** Target completion date */
deadline?: SortDirection;
/** Timestamp of last modification */
updatedAt?: SortDirection;
}
export type ProjectStatus = 'active' | 'archived' | 'completed' | 'paused';
export type ProjectStatusFilter = ProjectStatus | { eq?: ProjectStatus; in?: ProjectStatus[] };
export interface ProjectUpdatePayload {
/** Target completion date */
deadline?: null | string;
/** Detailed project description */
description?: null | string;
/** Human-readable project name */
name?: string;
/** Project priority for resource allocation */
priority?: ProjectPriority;
/** Current project lifecycle status */
status?: ProjectStatus;
}
export interface ProjectUpdateSuccessResponseBody {
meta?: Record<string, unknown>;
project: Project;
}
export interface ProjectsCreateRequest {
body: ProjectsCreateRequestBody;
}
export interface ProjectsCreateRequestBody {
project: ProjectCreatePayload;
}
export interface ProjectsCreateResponse {
body: ProjectsCreateResponseBody;
}
export type ProjectsCreateResponseBody = ErrorResponseBody | ProjectCreateSuccessResponseBody;
export type ProjectsDestroyResponse = never;
export interface ProjectsIndexRequest {
query: ProjectsIndexRequestQuery;
}
export interface ProjectsIndexRequestQuery {
filter?: ProjectFilter | ProjectFilter[];
page?: ProjectPage;
sort?: ProjectSort | ProjectSort[];
}
export interface ProjectsIndexResponse {
body: ProjectsIndexResponseBody;
}
export type ProjectsIndexResponseBody = ErrorResponseBody | ProjectIndexSuccessResponseBody;
export interface ProjectsShowResponse {
body: ProjectsShowResponseBody;
}
export type ProjectsShowResponseBody = ErrorResponseBody | ProjectShowSuccessResponseBody;
export interface ProjectsUpdateRequest {
body: ProjectsUpdateRequestBody;
}
export interface ProjectsUpdateRequestBody {
project: ProjectUpdatePayload;
}
export interface ProjectsUpdateResponse {
body: ProjectsUpdateResponseBody;
}
export type ProjectsUpdateResponseBody = ErrorResponseBody | ProjectUpdateSuccessResponseBody;
export type SortDirection = 'asc' | 'desc';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:
"$ref": "#/components/schemas/projectIndexSuccessResponseBody"
description: Successful response
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:
"$ref": "#/components/schemas/projectCreateSuccessResponseBody"
description: Successful response
'422':
description: Unprocessable Entity
content:
application/json:
schema:
"$ref": "#/components/schemas/errorResponseBody"
"/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:
"$ref": "#/components/schemas/projectShowSuccessResponseBody"
description: Successful response
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:
"$ref": "#/components/schemas/projectUpdateSuccessResponseBody"
description: Successful response
'422':
description: Unprocessable Entity
content:
application/json:
schema:
"$ref": "#/components/schemas/errorResponseBody"
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: No content
components:
schemas:
error:
properties:
issues:
items:
"$ref": "#/components/schemas/issue"
type: array
layer:
enum:
- http
- contract
- domain
type: string
type: object
required:
- issues
- layer
errorResponseBody:
"$ref": "#/components/schemas/error"
issue:
properties:
code:
type: string
detail:
type: string
meta:
properties: {}
type: object
path:
items:
type: string
type: array
pointer:
type: string
type: object
required:
- code
- detail
- meta
- path
- pointer
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
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: object
required:
- name
projectCreateSuccessResponseBody:
properties:
meta:
properties: {}
type: object
project:
"$ref": "#/components/schemas/project"
type: object
required:
- project
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
projectIndexSuccessResponseBody:
properties:
pagination:
"$ref": "#/components/schemas/offsetPagination"
meta:
properties: {}
type: object
projects:
items:
"$ref": "#/components/schemas/project"
type: array
type: object
required:
- pagination
- projects
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
projectShowSuccessResponseBody:
properties:
meta:
properties: {}
type: object
project:
"$ref": "#/components/schemas/project"
type: object
required:
- project
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: object
projectUpdateSuccessResponseBody:
properties:
meta:
properties: {}
type: object
project:
"$ref": "#/components/schemas/project"
type: object
required:
- project