Filtering and Sorting
Complex queries with string patterns, numeric ranges, and logical operators
API Definition
config/apis/bold_falcon.rb
rb
# frozen_string_literal: true
Apiwork::API.define '/bold_falcon' do
key_format :camel
export :openapi
export :apiwork
resources :articles
endModels
app/models/bold_falcon/article.rb
rb
# frozen_string_literal: true
module BoldFalcon
class Article < ApplicationRecord
belongs_to :category, optional: true
enum :status, { draft: 0, archived: 1, published: 2 }
validates :title, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| body | text | ✓ | |
| category_id | string | ✓ | |
| created_at | datetime | ||
| published_on | date | ✓ | |
| rating | decimal | ✓ | |
| status | integer | 0 | |
| title | string | ||
| updated_at | datetime | ||
| view_count | integer | ✓ | 0 |
app/models/bold_falcon/category.rb
rb
# frozen_string_literal: true
module BoldFalcon
class Category < ApplicationRecord
has_many :articles, dependent: :nullify
validates :name, :slug, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| created_at | datetime | ||
| name | string | ||
| slug | string | ||
| updated_at | datetime |
Representations
app/representations/bold_falcon/article_representation.rb
rb
# frozen_string_literal: true
module BoldFalcon
class ArticleRepresentation < Apiwork::Representation::Base
attribute :id
attribute :title, filterable: true, writable: true
attribute :body, writable: true
attribute :status, filterable: true, sortable: true, writable: true
attribute :view_count, filterable: true, sortable: true
attribute :rating
attribute :published_on, filterable: true, sortable: true, writable: true
attribute :created_at, sortable: true
attribute :updated_at, sortable: true
belongs_to :category, filterable: true
end
endapp/representations/bold_falcon/category_representation.rb
rb
# frozen_string_literal: true
module BoldFalcon
class CategoryRepresentation < Apiwork::Representation::Base
attribute :id
attribute :name, filterable: true
attribute :slug
end
endContracts
app/contracts/bold_falcon/article_contract.rb
rb
# frozen_string_literal: true
module BoldFalcon
class ArticleContract < Apiwork::Contract::Base
representation ArticleRepresentation
end
endControllers
app/controllers/bold_falcon/articles_controller.rb
rb
# frozen_string_literal: true
module BoldFalcon
class ArticlesController < ApplicationController
before_action :set_article, only: %i[show update destroy]
def index
articles = Article.all
expose articles
end
def show
expose article
end
def create
article = Article.create(contract.body[:article])
expose article
end
def update
article.update(contract.body[:article])
expose article
end
def destroy
article.destroy
expose article
end
private
attr_reader :article
def set_article
@article = Article.find(params[:id])
end
end
endRequest Examples
Filter by status
Request
http
GET /bold_falcon/articles?filter[status][eq]=publishedResponse 200
json
{
"articles": [
{
"id": "980bb55a-45bc-531b-a571-31b7d4d0a0ce",
"title": "Published Article",
"body": null,
"status": "published",
"viewCount": 0,
"rating": null,
"publishedOn": null,
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
}
],
"pagination": {
"items": 1,
"total": 1,
"current": 1,
"next": null,
"prev": null
}
}Filter by title pattern
Request
http
GET /bold_falcon/articles?filter[title][contains]=RailsResponse 200
json
{
"articles": [
{
"id": "980bb55a-45bc-531b-a571-31b7d4d0a0ce",
"title": "Getting Started with Rails",
"body": null,
"status": "published",
"viewCount": 0,
"rating": null,
"publishedOn": null,
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
}
],
"pagination": {
"items": 1,
"total": 1,
"current": 1,
"next": null,
"prev": null
}
}Sort by date
Request
http
GET /bold_falcon/articles?sort[published_on]=descResponse 200
json
{
"articles": [
{
"id": "66187cb1-6c7d-57b9-95bb-6de6ad564dad",
"title": "New Article",
"body": null,
"status": "published",
"viewCount": 0,
"rating": null,
"publishedOn": "2024-06-01",
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
},
{
"id": "980bb55a-45bc-531b-a571-31b7d4d0a0ce",
"title": "Old Article",
"body": null,
"status": "published",
"viewCount": 0,
"rating": null,
"publishedOn": "2024-01-01",
"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
}
}Multiple sort fields
Request
http
GET /bold_falcon/articles?sort[status]=asc&sort[published_on]=descResponse 200
json
{
"articles": [
{
"id": "e8c30b71-ec2b-5287-ba57-5143a67ded78",
"title": "Draft 2",
"body": null,
"status": "draft",
"viewCount": 0,
"rating": null,
"publishedOn": "2024-03-01",
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
},
{
"id": "980bb55a-45bc-531b-a571-31b7d4d0a0ce",
"title": "Draft 1",
"body": null,
"status": "draft",
"viewCount": 0,
"rating": null,
"publishedOn": "2024-01-01",
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
},
{
"id": "66187cb1-6c7d-57b9-95bb-6de6ad564dad",
"title": "Published 1",
"body": null,
"status": "published",
"viewCount": 0,
"rating": null,
"publishedOn": "2024-02-01",
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
}
],
"pagination": {
"items": 3,
"total": 1,
"current": 1,
"next": null,
"prev": null
}
}Filter by date range
Request
http
GET /bold_falcon/articles?filter[published_on][gte]=2024-01-01&filter[published_on][lt]=2024-02-01Response 200
json
{
"articles": [
{
"id": "980bb55a-45bc-531b-a571-31b7d4d0a0ce",
"title": "January Article",
"body": null,
"status": "published",
"viewCount": 0,
"rating": null,
"publishedOn": "2024-01-15",
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
}
],
"pagination": {
"items": 1,
"total": 1,
"current": 1,
"next": null,
"prev": null
}
}Filter by view count
Request
http
GET /bold_falcon/articles?filter[view_count][gt]=100Response 200
json
{
"articles": [
{
"id": "980bb55a-45bc-531b-a571-31b7d4d0a0ce",
"title": "Popular Article",
"body": null,
"status": "published",
"viewCount": 500,
"rating": null,
"publishedOn": null,
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
}
],
"pagination": {
"items": 1,
"total": 1,
"current": 1,
"next": null,
"prev": null
}
}Combined filter and sort
Request
http
GET /bold_falcon/articles?filter[status][eq]=published&sort[view_count]=descResponse 200
json
{
"articles": [
{
"id": "980bb55a-45bc-531b-a571-31b7d4d0a0ce",
"title": "Popular Published",
"body": null,
"status": "published",
"viewCount": 1000,
"rating": null,
"publishedOn": null,
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
},
{
"id": "e8c30b71-ec2b-5287-ba57-5143a67ded78",
"title": "Less Popular Published",
"body": null,
"status": "published",
"viewCount": 100,
"rating": null,
"publishedOn": 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
}
}Filter by category
Request
http
GET /bold_falcon/articles?filter[category][name][eq]=TechnologyResponse 200
json
{
"articles": [
{
"id": "980bb55a-45bc-531b-a571-31b7d4d0a0ce",
"title": "Tech Article",
"body": null,
"status": "published",
"viewCount": 0,
"rating": null,
"publishedOn": null,
"createdAt": "2026-04-01T12:00:00.000Z",
"updatedAt": "2026-04-01T12:00:00.000Z"
}
],
"pagination": {
"items": 1,
"total": 1,
"current": 1,
"next": null,
"prev": null
}
}Exports
OpenAPI
yml
---
openapi: 3.1.0
info:
title: "/bold_falcon"
version: 1.0.0
paths:
"/articles":
get:
operationId: articlesIndex
parameters:
- in: query
name: filter
required: false
schema:
oneOf:
- "$ref": "#/components/schemas/articleFilter"
- items:
"$ref": "#/components/schemas/articleFilter"
type: array
- in: query
name: include
required: false
schema:
"$ref": "#/components/schemas/articleInclude"
- in: query
name: page
required: false
schema:
"$ref": "#/components/schemas/articlePage"
- in: query
name: sort
required: false
schema:
oneOf:
- "$ref": "#/components/schemas/articleSort"
- items:
"$ref": "#/components/schemas/articleSort"
type: array
responses:
'200':
content:
application/json:
schema:
properties:
articles:
items:
"$ref": "#/components/schemas/article"
type: array
meta:
properties: {}
type: object
pagination:
"$ref": "#/components/schemas/offsetPagination"
type: object
required:
- articles
- pagination
description: ''
post:
operationId: articlesCreate
parameters:
- in: query
name: include
required: false
schema:
"$ref": "#/components/schemas/articleInclude"
requestBody:
content:
application/json:
schema:
properties:
article:
"$ref": "#/components/schemas/articleCreatePayload"
type: object
required:
- article
required: true
responses:
'200':
content:
application/json:
schema:
properties:
article:
"$ref": "#/components/schemas/article"
meta:
properties: {}
type: object
type: object
required:
- article
description: ''
'422':
description: Unprocessable Entity
content:
application/json:
schema:
properties:
issues:
items:
"$ref": "#/components/schemas/error"
type: array
required:
- issues
type: object
"/articles/{id}":
get:
operationId: articlesShow
parameters:
- in: path
name: id
required: true
schema:
type: string
- in: query
name: include
required: false
schema:
"$ref": "#/components/schemas/articleInclude"
responses:
'200':
content:
application/json:
schema:
properties:
article:
"$ref": "#/components/schemas/article"
meta:
properties: {}
type: object
type: object
required:
- article
description: ''
patch:
operationId: articlesUpdate
parameters:
- in: path
name: id
required: true
schema:
type: string
- in: query
name: include
required: false
schema:
"$ref": "#/components/schemas/articleInclude"
requestBody:
content:
application/json:
schema:
properties:
article:
"$ref": "#/components/schemas/articleUpdatePayload"
type: object
required:
- article
required: true
responses:
'200':
content:
application/json:
schema:
properties:
article:
"$ref": "#/components/schemas/article"
meta:
properties: {}
type: object
type: object
required:
- article
description: ''
'422':
description: Unprocessable Entity
content:
application/json:
schema:
properties:
issues:
items:
"$ref": "#/components/schemas/error"
type: array
required:
- issues
type: object
delete:
operationId: articlesDestroy
parameters:
- in: path
name: id
required: true
schema:
type: string
- in: query
name: include
required: false
schema:
"$ref": "#/components/schemas/articleInclude"
responses:
'204':
description: ''
components:
schemas:
article:
properties:
body:
type:
- string
- 'null'
category:
oneOf:
- "$ref": "#/components/schemas/category"
- type: 'null'
createdAt:
type: string
format: date-time
id:
type: string
publishedOn:
type:
- string
- 'null'
format: date
rating:
type:
- number
- 'null'
status:
enum:
- draft
- archived
- published
type: string
title:
type: string
updatedAt:
type: string
format: date-time
viewCount:
type:
- integer
- 'null'
type: object
required:
- body
- createdAt
- id
- publishedOn
- rating
- status
- title
- updatedAt
- viewCount
articleCreatePayload:
properties:
body:
type:
- string
- 'null'
default:
publishedOn:
type:
- string
- 'null'
format: date
default:
status:
enum:
- draft
- archived
- published
type: string
title:
type: string
type: object
required:
- title
articleFilter:
properties:
AND:
items:
"$ref": "#/components/schemas/articleFilter"
type: array
NOT:
"$ref": "#/components/schemas/articleFilter"
OR:
items:
"$ref": "#/components/schemas/articleFilter"
type: array
category:
"$ref": "#/components/schemas/categoryFilter"
publishedOn:
oneOf:
- type: string
format: date
- "$ref": "#/components/schemas/nullableDateFilter"
status:
"$ref": "#/components/schemas/articleStatusFilter"
title:
oneOf:
- type: string
- "$ref": "#/components/schemas/stringFilter"
viewCount:
oneOf:
- type: integer
- "$ref": "#/components/schemas/nullableIntegerFilter"
type: object
articleInclude:
properties:
category:
type: boolean
type: object
articlePage:
properties:
number:
type: integer
minimum: 1
size:
type: integer
minimum: 1
maximum: 100
type: object
articleSort:
properties:
createdAt:
enum:
- asc
- desc
type: string
publishedOn:
enum:
- asc
- desc
type: string
status:
enum:
- asc
- desc
type: string
updatedAt:
enum:
- asc
- desc
type: string
viewCount:
enum:
- asc
- desc
type: string
type: object
articleStatusFilter:
oneOf:
- enum:
- draft
- archived
- published
type: string
- properties:
eq:
enum:
- draft
- archived
- published
type: string
in:
items:
enum:
- draft
- archived
- published
type: string
type: array
type: object
required:
- eq
- in
articleUpdatePayload:
properties:
body:
type:
- string
- 'null'
publishedOn:
type:
- string
- 'null'
format: date
status:
enum:
- draft
- archived
- published
type: string
title:
type: string
type: object
category:
properties:
id:
type: string
name:
type: string
slug:
type: string
type: object
required:
- id
- name
- slug
categoryFilter:
properties:
AND:
items:
"$ref": "#/components/schemas/categoryFilter"
type: array
NOT:
"$ref": "#/components/schemas/categoryFilter"
OR:
items:
"$ref": "#/components/schemas/categoryFilter"
type: array
name:
oneOf:
- type: string
- "$ref": "#/components/schemas/stringFilter"
type: object
dateFilterBetween:
properties:
from:
type: string
format: date
to:
type: string
format: date
type: object
error:
properties:
issues:
items:
"$ref": "#/components/schemas/errorIssue"
type: array
layer:
enum:
- http
- contract
- domain
type: string
type: object
required:
- issues
- layer
errorIssue:
properties:
code:
type: string
detail:
type: string
meta:
properties: {}
type: object
path:
items:
oneOf:
- type: string
- type: integer
type: array
pointer:
type: string
type: object
required:
- code
- detail
- meta
- path
- pointer
integerFilterBetween:
properties:
from:
type: integer
to:
type: integer
type: object
nullableDateFilter:
properties:
between:
"$ref": "#/components/schemas/dateFilterBetween"
eq:
type: string
format: date
gt:
type: string
format: date
gte:
type: string
format: date
in:
items:
type: string
format: date
type: array
lt:
type: string
format: date
lte:
type: string
format: date
'null':
type: boolean
type: object
nullableIntegerFilter:
properties:
between:
"$ref": "#/components/schemas/integerFilterBetween"
eq:
type: integer
gt:
type: integer
gte:
type: integer
in:
items:
type: integer
type: array
lt:
type: integer
lte:
type: integer
'null':
type: boolean
type: object
offsetPagination:
properties:
current:
type: integer
items:
type: integer
next:
type:
- integer
- 'null'
prev:
type:
- integer
- 'null'
total:
type: integer
type: object
required:
- current
- items
- total
stringFilter:
properties:
contains:
type: string
endsWith:
type: string
eq:
type: string
in:
items:
type: string
type: array
startsWith:
type: string
type: objectApiwork
json
{
"base_path": "/bold_falcon",
"enums": [
{
"deprecated": false,
"description": null,
"example": null,
"name": "article_status",
"scope": "article",
"values": [
"draft",
"archived",
"published"
]
},
{
"deprecated": false,
"description": null,
"example": null,
"name": "error_layer",
"scope": null,
"values": [
"http",
"contract",
"domain"
]
},
{
"deprecated": false,
"description": null,
"example": null,
"name": "sort_direction",
"scope": null,
"values": [
"asc",
"desc"
]
}
],
"error_codes": [
{
"description": "Unprocessable Entity",
"name": "unprocessable_entity",
"status": 422
}
],
"fingerprint": "9832a96dd879df0f",
"info": null,
"locales": [],
"resources": [
{
"actions": [
{
"name": "articles.index",
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/articles",
"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": "article_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": "article_filter"
}
}
]
},
{
"name": "include",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "article_include"
},
{
"name": "page",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "article_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": "article_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": "article_sort"
}
}
]
}
]
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "articles",
"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": "article"
}
},
{
"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"
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "articles.show",
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/articles/:id",
"raises": [],
"request": {
"body": [],
"description": null,
"query": [
{
"name": "include",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "article_include"
}
]
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "article",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "article"
},
{
"name": "meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": []
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "articles.create",
"deprecated": false,
"description": null,
"method": "post",
"operation_id": null,
"path": "/articles",
"raises": [
"unprocessable_entity"
],
"request": {
"body": [
{
"name": "article",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "article_create_payload"
}
],
"description": null,
"query": [
{
"name": "include",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "article_include"
}
]
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "article",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "article"
},
{
"name": "meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": []
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "articles.update",
"deprecated": false,
"description": null,
"method": "patch",
"operation_id": null,
"path": "/articles/:id",
"raises": [
"unprocessable_entity"
],
"request": {
"body": [
{
"name": "article",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "article_update_payload"
}
],
"description": null,
"query": [
{
"name": "include",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "article_include"
}
]
},
"response": {
"body": {
"deprecated": null,
"description": null,
"nullable": null,
"optional": null,
"type": "object",
"partial": null,
"shape": [
{
"name": "article",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "article"
},
{
"name": "meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": []
}
]
},
"description": null,
"no_content": false
},
"summary": null,
"tags": []
},
{
"name": "articles.destroy",
"deprecated": false,
"description": null,
"method": "delete",
"operation_id": null,
"path": "/articles/:id",
"raises": [],
"request": {
"body": [],
"description": null,
"query": [
{
"name": "include",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "article_include"
}
]
},
"response": {
"body": null,
"description": null,
"no_content": true
},
"summary": null,
"tags": []
}
],
"identifier": "articles",
"name": "articles",
"parent_identifiers": [],
"path": "articles",
"resources": [],
"scope": "article"
}
],
"types": [
{
"recursive": true,
"deprecated": false,
"description": null,
"example": null,
"name": "article_filter",
"scope": "article",
"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": "article_filter"
}
},
{
"name": "NOT",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "article_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": "article_filter"
}
},
{
"name": "category",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "category_filter"
},
{
"name": "publishedOn",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "date",
"example": null
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "nullable_date_filter"
}
]
},
{
"name": "status",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "article_status_filter"
},
{
"name": "title",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "string_filter"
}
]
},
{
"name": "viewCount",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "nullable_integer_filter"
}
]
}
]
},
{
"recursive": true,
"deprecated": false,
"description": null,
"example": null,
"name": "category_filter",
"scope": "category",
"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": "category_filter"
}
},
{
"name": "NOT",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "category_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": "category_filter"
}
},
{
"name": "name",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "string_filter"
}
]
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "article_create_payload",
"scope": "article",
"type": "object",
"extends": [],
"shape": [
{
"name": "body",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "string",
"default": null,
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "publishedOn",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "date",
"default": null,
"example": null
},
{
"name": "status",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"default": "draft",
"enum": "article_status",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "title",
"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": "article_include",
"scope": "article",
"type": "object",
"extends": [],
"shape": [
{
"name": "category",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "boolean",
"example": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "article_page",
"scope": "article",
"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": "article_sort",
"scope": "article",
"type": "object",
"extends": [],
"shape": [
{
"name": "createdAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
},
{
"name": "publishedOn",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
},
{
"name": "status",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
},
{
"name": "updatedAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
},
{
"name": "viewCount",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "sort_direction"
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "article_status_filter",
"scope": "article",
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "article_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": "article_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": "article_status"
}
}
]
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "article_update_payload",
"scope": "article",
"type": "object",
"extends": [],
"shape": [
{
"name": "body",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "publishedOn",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "date",
"example": null
},
{
"name": "status",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"enum": "article_status",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "title",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "category",
"scope": "category",
"type": "object",
"extends": [],
"shape": [
{
"name": "id",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "name",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "slug",
"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": "date_filter_between",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "from",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "date",
"example": null
},
{
"name": "to",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "date",
"example": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "error_issue",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "code",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "detail",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "meta",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "object",
"partial": false,
"shape": []
},
{
"name": "path",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "union",
"discriminator": "",
"variants": [
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
}
},
{
"name": "pointer",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "integer_filter_between",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "from",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "to",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "offset_pagination",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "current",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "items",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "next",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "prev",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "total",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "string_filter",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "contains",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "endsWith",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "eq",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "in",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
}
},
{
"name": "startsWith",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "article",
"scope": "article",
"type": "object",
"extends": [],
"shape": [
{
"name": "body",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "category",
"deprecated": false,
"description": null,
"nullable": true,
"optional": true,
"type": "reference",
"reference": "category"
},
{
"name": "createdAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
},
{
"name": "id",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "publishedOn",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "date",
"example": null
},
{
"name": "rating",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "decimal",
"example": null,
"max": null,
"min": null
},
{
"name": "status",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"enum": "article_status",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "title",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "string",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "updatedAt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "datetime",
"example": null
},
{
"name": "viewCount",
"deprecated": false,
"description": null,
"nullable": true,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "error",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "issues",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "error_issue"
}
},
{
"name": "layer",
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "error_layer"
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "nullable_date_filter",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "between",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "date_filter_between"
},
{
"name": "eq",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "date",
"example": null
},
{
"name": "gt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "date",
"example": null
},
{
"name": "gte",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "date",
"example": null
},
{
"name": "in",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "date",
"example": null
}
},
{
"name": "lt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "date",
"example": null
},
{
"name": "lte",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "date",
"example": null
},
{
"name": "null",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "boolean",
"example": null
}
]
},
{
"recursive": false,
"deprecated": false,
"description": null,
"example": null,
"name": "nullable_integer_filter",
"scope": null,
"type": "object",
"extends": [],
"shape": [
{
"name": "between",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "integer_filter_between"
},
{
"name": "eq",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "gt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "gte",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "in",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "array",
"example": null,
"max": null,
"min": null,
"of": {
"deprecated": false,
"description": null,
"nullable": false,
"optional": false,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
}
},
{
"name": "lt",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "lte",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "integer",
"example": null,
"format": null,
"max": null,
"min": null
},
{
"name": "null",
"deprecated": false,
"description": null,
"nullable": false,
"optional": true,
"type": "boolean",
"example": null
}
]
}
]
}Codegen
TypeScript
ts
export type ErrorLayer = 'http' | 'contract' | 'domain';
export type SortDirection = 'asc' | 'desc';
export interface DateFilterBetween {
from?: string;
to?: string;
}
export interface ErrorIssue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string | number[];
pointer: string;
}
export interface IntegerFilterBetween {
from?: number;
to?: number;
}
export interface OffsetPagination {
current: number;
items: number;
next?: number | null;
prev?: number | null;
total: number;
}
export interface StringFilter {
contains?: string;
endsWith?: string;
eq?: string;
in?: string[];
startsWith?: string;
}
export interface Error {
issues: ErrorIssue[];
layer: ErrorLayer;
}
export interface NullableDateFilter {
between?: DateFilterBetween;
eq?: string;
gt?: string;
gte?: string;
in?: string[];
lt?: string;
lte?: string;
null?: boolean;
}
export interface NullableIntegerFilter {
between?: IntegerFilterBetween;
eq?: number;
gt?: number;
gte?: number;
in?: number[];
lt?: number;
lte?: number;
null?: boolean;
}ts
import type {
NullableDateFilter,
NullableIntegerFilter,
SortDirection,
StringFilter,
} from '../api';
import type { Category, CategoryFilter } from './category';
export type ArticleStatus = 'draft' | 'archived' | 'published';
export interface ArticleFilter {
AND?: ArticleFilter[];
category?: CategoryFilter;
NOT?: ArticleFilter;
OR?: ArticleFilter[];
publishedOn?: string | NullableDateFilter;
status?: ArticleStatusFilter;
title?: string | StringFilter;
viewCount?: number | NullableIntegerFilter;
}
export interface ArticleCreatePayload {
body?: string | null;
publishedOn?: string | null;
status?: ArticleStatus;
title: string;
}
export interface ArticleInclude {
category?: boolean;
}
export interface ArticlePage {
number?: number;
size?: number;
}
export interface ArticleSort {
createdAt?: SortDirection;
publishedOn?: SortDirection;
status?: SortDirection;
updatedAt?: SortDirection;
viewCount?: SortDirection;
}
export type ArticleStatusFilter =
| ArticleStatus
| { eq?: ArticleStatus; in?: ArticleStatus[] };
export interface ArticleUpdatePayload {
body?: string | null;
publishedOn?: string | null;
status?: ArticleStatus;
title?: string;
}
export interface Article {
body: string | null;
category?: Category | null;
createdAt: string;
id: string;
publishedOn: string | null;
rating: number | null;
status: ArticleStatus;
title: string;
updatedAt: string;
viewCount: number | null;
}ts
import type { StringFilter } from '../api';
export interface CategoryFilter {
AND?: CategoryFilter[];
NOT?: CategoryFilter;
name?: string | StringFilter;
OR?: CategoryFilter[];
}
export interface Category {
id: string;
name: string;
slug: string;
}ts
export * from './article';
export * from './category';ts
import type { OffsetPagination } from '../api';
import type {
Article,
ArticleCreatePayload,
ArticleFilter,
ArticleInclude,
ArticlePage,
ArticleSort,
ArticleUpdatePayload,
} from '../domains/article';
export type ArticlesIndexMethod = 'GET';
export type ArticlesIndexPath = '/articles';
export interface ArticlesIndexRequestQuery {
filter?: ArticleFilter | ArticleFilter[];
include?: ArticleInclude;
page?: ArticlePage;
sort?: ArticleSort | ArticleSort[];
}
export type ArticlesIndexResponseBody = {
articles: Article[];
meta?: Record<string, unknown>;
pagination: OffsetPagination;
};
export interface ArticlesIndexRequest {
query: ArticlesIndexRequestQuery;
}
export interface ArticlesIndexResponse {
body: ArticlesIndexResponseBody;
}
export interface ArticlesIndex {
method: ArticlesIndexMethod;
path: ArticlesIndexPath;
request: ArticlesIndexRequest;
response: ArticlesIndexResponse;
}
export type ArticlesShowMethod = 'GET';
export type ArticlesShowPath = '/articles/:id';
export interface ArticlesShowPathParams {
id: string;
}
export interface ArticlesShowRequestQuery {
include?: ArticleInclude;
}
export type ArticlesShowResponseBody = {
article: Article;
meta?: Record<string, unknown>;
};
export interface ArticlesShowRequest {
query: ArticlesShowRequestQuery;
}
export interface ArticlesShowResponse {
body: ArticlesShowResponseBody;
}
export interface ArticlesShow {
method: ArticlesShowMethod;
path: ArticlesShowPath;
pathParams: ArticlesShowPathParams;
request: ArticlesShowRequest;
response: ArticlesShowResponse;
}
export type ArticlesCreateMethod = 'POST';
export type ArticlesCreatePath = '/articles';
export interface ArticlesCreateRequestQuery {
include?: ArticleInclude;
}
export interface ArticlesCreateRequestBody {
article: ArticleCreatePayload;
}
export type ArticlesCreateResponseBody = {
article: Article;
meta?: Record<string, unknown>;
};
export interface ArticlesCreateRequest {
body: ArticlesCreateRequestBody;
query: ArticlesCreateRequestQuery;
}
export interface ArticlesCreateResponse {
body: ArticlesCreateResponseBody;
}
export type ArticlesCreateErrors = 422;
export interface ArticlesCreate {
errors: ArticlesCreateErrors;
method: ArticlesCreateMethod;
path: ArticlesCreatePath;
request: ArticlesCreateRequest;
response: ArticlesCreateResponse;
}
export type ArticlesUpdateMethod = 'PATCH';
export type ArticlesUpdatePath = '/articles/:id';
export interface ArticlesUpdatePathParams {
id: string;
}
export interface ArticlesUpdateRequestQuery {
include?: ArticleInclude;
}
export interface ArticlesUpdateRequestBody {
article: ArticleUpdatePayload;
}
export type ArticlesUpdateResponseBody = {
article: Article;
meta?: Record<string, unknown>;
};
export interface ArticlesUpdateRequest {
body: ArticlesUpdateRequestBody;
query: ArticlesUpdateRequestQuery;
}
export interface ArticlesUpdateResponse {
body: ArticlesUpdateResponseBody;
}
export type ArticlesUpdateErrors = 422;
export interface ArticlesUpdate {
errors: ArticlesUpdateErrors;
method: ArticlesUpdateMethod;
path: ArticlesUpdatePath;
pathParams: ArticlesUpdatePathParams;
request: ArticlesUpdateRequest;
response: ArticlesUpdateResponse;
}
export type ArticlesDestroyMethod = 'DELETE';
export type ArticlesDestroyPath = '/articles/:id';
export interface ArticlesDestroyPathParams {
id: string;
}
export interface ArticlesDestroyRequestQuery {
include?: ArticleInclude;
}
export interface ArticlesDestroyRequest {
query: ArticlesDestroyRequestQuery;
}
export interface ArticlesDestroy {
method: ArticlesDestroyMethod;
path: ArticlesDestroyPath;
pathParams: ArticlesDestroyPathParams;
request: ArticlesDestroyRequest;
}ts
export * from './articles';Zod
ts
import * as z from 'zod';
export const ErrorLayerSchema = z.enum(['contract', 'domain', 'http']);
export const SortDirectionSchema = z.enum(['asc', 'desc']);
export const DateFilterBetweenSchema = z.object({
from: z.iso.date().optional(),
to: z.iso.date().optional(),
});
export const ErrorIssueSchema = z.object({
code: z.string(),
detail: z.string(),
meta: z.record(z.string(), z.unknown()),
path: z.array(z.union([z.string(), z.number().int()])),
pointer: z.string(),
});
export const IntegerFilterBetweenSchema = z.object({
from: z.number().int().optional(),
to: z.number().int().optional(),
});
export const OffsetPaginationSchema = z.object({
current: z.number().int(),
items: z.number().int(),
next: z.number().int().nullable().optional(),
prev: z.number().int().nullable().optional(),
total: z.number().int(),
});
export const StringFilterSchema = z.object({
contains: z.string().optional(),
endsWith: z.string().optional(),
eq: z.string().optional(),
in: z.array(z.string()).optional(),
startsWith: z.string().optional(),
});
export const ErrorSchema = z.object({
issues: z.array(ErrorIssueSchema),
layer: ErrorLayerSchema,
});
export const NullableDateFilterSchema = z.object({
between: DateFilterBetweenSchema.optional(),
eq: z.iso.date().optional(),
gt: z.iso.date().optional(),
gte: z.iso.date().optional(),
in: z.array(z.iso.date()).optional(),
lt: z.iso.date().optional(),
lte: z.iso.date().optional(),
null: z.boolean().optional(),
});
export const NullableIntegerFilterSchema = z.object({
between: IntegerFilterBetweenSchema.optional(),
eq: z.number().int().optional(),
gt: z.number().int().optional(),
gte: z.number().int().optional(),
in: z.array(z.number().int()).optional(),
lt: z.number().int().optional(),
lte: z.number().int().optional(),
null: z.boolean().optional(),
});
export type ErrorLayer = 'contract' | 'domain' | 'http';
export type SortDirection = 'asc' | 'desc';
export interface DateFilterBetween {
from?: string;
to?: string;
}
export interface ErrorIssue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string | number[];
pointer: string;
}
export interface IntegerFilterBetween {
from?: number;
to?: number;
}
export interface OffsetPagination {
current: number;
items: number;
next?: number | null;
prev?: number | null;
total: number;
}
export interface StringFilter {
contains?: string;
endsWith?: string;
eq?: string;
in?: string[];
startsWith?: string;
}
export interface Error {
issues: ErrorIssue[];
layer: ErrorLayer;
}
export interface NullableDateFilter {
between?: DateFilterBetween;
eq?: string;
gt?: string;
gte?: string;
in?: string[];
lt?: string;
lte?: string;
null?: boolean;
}
export interface NullableIntegerFilter {
between?: IntegerFilterBetween;
eq?: number;
gt?: number;
gte?: number;
in?: number[];
lt?: number;
lte?: number;
null?: boolean;
}ts
import type {
NullableDateFilter,
NullableIntegerFilter,
SortDirection,
StringFilter,
} from '../api';
import type { Category, CategoryFilter } from './category';
import * as z from 'zod';
import {
NullableDateFilterSchema,
NullableIntegerFilterSchema,
SortDirectionSchema,
StringFilterSchema,
} from '../api';
import { CategoryFilterSchema, CategorySchema } from './category';
export const ArticleStatusSchema = z.enum(['archived', 'draft', 'published']);
export const ArticleFilterSchema: z.ZodType<ArticleFilter> = z.lazy(() =>
z.object({
AND: z.array(ArticleFilterSchema).optional(),
category: CategoryFilterSchema.optional(),
NOT: ArticleFilterSchema.optional(),
OR: z.array(ArticleFilterSchema).optional(),
publishedOn: z.union([z.iso.date(), NullableDateFilterSchema]).optional(),
status: ArticleStatusFilterSchema.optional(),
title: z.union([z.string(), StringFilterSchema]).optional(),
viewCount: z
.union([z.number().int(), NullableIntegerFilterSchema])
.optional(),
}),
);
export const ArticleCreatePayloadSchema = z.object({
body: z.string().nullable().default(null),
publishedOn: z.iso.date().nullable().default(null),
status: ArticleStatusSchema.default('draft'),
title: z.string(),
});
export const ArticleIncludeSchema = z.object({
category: z.boolean().optional(),
});
export const ArticlePageSchema = z.object({
number: z.number().int().min(1).optional(),
size: z.number().int().min(1).max(100).optional(),
});
export const ArticleSortSchema = z.object({
createdAt: SortDirectionSchema.optional(),
publishedOn: SortDirectionSchema.optional(),
status: SortDirectionSchema.optional(),
updatedAt: SortDirectionSchema.optional(),
viewCount: SortDirectionSchema.optional(),
});
export const ArticleStatusFilterSchema = z.union([
ArticleStatusSchema,
z
.object({ eq: ArticleStatusSchema, in: z.array(ArticleStatusSchema) })
.partial(),
]);
export const ArticleUpdatePayloadSchema = z.object({
body: z.string().nullable().optional(),
publishedOn: z.iso.date().nullable().optional(),
status: ArticleStatusSchema.optional(),
title: z.string().optional(),
});
export const ArticleSchema = z.object({
body: z.string().nullable(),
category: CategorySchema.nullable().optional(),
createdAt: z.iso.datetime(),
id: z.string(),
publishedOn: z.iso.date().nullable(),
rating: z.number().nullable(),
status: ArticleStatusSchema,
title: z.string(),
updatedAt: z.iso.datetime(),
viewCount: z.number().int().nullable(),
});
export type ArticleStatus = 'archived' | 'draft' | 'published';
export interface ArticleFilter {
AND?: ArticleFilter[];
category?: CategoryFilter;
NOT?: ArticleFilter;
OR?: ArticleFilter[];
publishedOn?: string | NullableDateFilter;
status?: ArticleStatusFilter;
title?: string | StringFilter;
viewCount?: number | NullableIntegerFilter;
}
export interface ArticleCreatePayload {
body?: string | null;
publishedOn?: string | null;
status?: ArticleStatus;
title: string;
}
export interface ArticleInclude {
category?: boolean;
}
export interface ArticlePage {
number?: number;
size?: number;
}
export interface ArticleSort {
createdAt?: SortDirection;
publishedOn?: SortDirection;
status?: SortDirection;
updatedAt?: SortDirection;
viewCount?: SortDirection;
}
export type ArticleStatusFilter =
| ArticleStatus
| { eq?: ArticleStatus; in?: ArticleStatus[] };
export interface ArticleUpdatePayload {
body?: string | null;
publishedOn?: string | null;
status?: ArticleStatus;
title?: string;
}
export interface Article {
body: string | null;
category?: Category | null;
createdAt: string;
id: string;
publishedOn: string | null;
rating: number | null;
status: ArticleStatus;
title: string;
updatedAt: string;
viewCount: number | null;
}ts
import type { StringFilter } from '../api';
import * as z from 'zod';
import { StringFilterSchema } from '../api';
export const CategoryFilterSchema: z.ZodType<CategoryFilter> = z.lazy(() =>
z.object({
AND: z.array(CategoryFilterSchema).optional(),
NOT: CategoryFilterSchema.optional(),
name: z.union([z.string(), StringFilterSchema]).optional(),
OR: z.array(CategoryFilterSchema).optional(),
}),
);
export const CategorySchema = z.object({
id: z.string(),
name: z.string(),
slug: z.string(),
});
export interface CategoryFilter {
AND?: CategoryFilter[];
NOT?: CategoryFilter;
name?: string | StringFilter;
OR?: CategoryFilter[];
}
export interface Category {
id: string;
name: string;
slug: string;
}ts
export * from './article';
export * from './category';ts
import type { OffsetPagination } from '../api';
import type {
Article,
ArticleCreatePayload,
ArticleFilter,
ArticleInclude,
ArticlePage,
ArticleSort,
ArticleUpdatePayload,
} from '../domains/article';
import * as z from 'zod';
import { OffsetPaginationSchema } from '../api';
import {
ArticleCreatePayloadSchema,
ArticleFilterSchema,
ArticleIncludeSchema,
ArticlePageSchema,
ArticleSchema,
ArticleSortSchema,
ArticleUpdatePayloadSchema,
} from '../domains/article';
export const ArticlesIndexRequestQuerySchema = z.object({
filter: z
.union([ArticleFilterSchema, z.array(ArticleFilterSchema)])
.optional(),
include: ArticleIncludeSchema.optional(),
page: ArticlePageSchema.optional(),
sort: z.union([ArticleSortSchema, z.array(ArticleSortSchema)]).optional(),
});
export const ArticlesIndexResponseBodySchema = z.object({
articles: z.array(ArticleSchema),
meta: z.record(z.string(), z.unknown()).optional(),
pagination: OffsetPaginationSchema,
});
export const ArticlesShowPathParamsSchema = z.object({ id: z.string() });
export const ArticlesShowRequestQuerySchema = z.object({
include: ArticleIncludeSchema.optional(),
});
export const ArticlesShowResponseBodySchema = z.object({
article: ArticleSchema,
meta: z.record(z.string(), z.unknown()).optional(),
});
export const ArticlesCreateRequestQuerySchema = z.object({
include: ArticleIncludeSchema.optional(),
});
export const ArticlesCreateRequestBodySchema = z.object({
article: ArticleCreatePayloadSchema,
});
export const ArticlesCreateResponseBodySchema = z.object({
article: ArticleSchema,
meta: z.record(z.string(), z.unknown()).optional(),
});
export const ArticlesUpdatePathParamsSchema = z.object({ id: z.string() });
export const ArticlesUpdateRequestQuerySchema = z.object({
include: ArticleIncludeSchema.optional(),
});
export const ArticlesUpdateRequestBodySchema = z.object({
article: ArticleUpdatePayloadSchema,
});
export const ArticlesUpdateResponseBodySchema = z.object({
article: ArticleSchema,
meta: z.record(z.string(), z.unknown()).optional(),
});
export const ArticlesDestroyPathParamsSchema = z.object({ id: z.string() });
export const ArticlesDestroyRequestQuerySchema = z.object({
include: ArticleIncludeSchema.optional(),
});
export type ArticlesIndexMethod = 'GET';
export type ArticlesIndexPath = '/articles';
export interface ArticlesIndexRequestQuery {
filter?: ArticleFilter | ArticleFilter[];
include?: ArticleInclude;
page?: ArticlePage;
sort?: ArticleSort | ArticleSort[];
}
export type ArticlesIndexResponseBody = {
articles: Article[];
meta?: Record<string, unknown>;
pagination: OffsetPagination;
};
export interface ArticlesIndexRequest {
query: ArticlesIndexRequestQuery;
}
export interface ArticlesIndexResponse {
body: ArticlesIndexResponseBody;
}
export interface ArticlesIndex {
method: ArticlesIndexMethod;
path: ArticlesIndexPath;
request: ArticlesIndexRequest;
response: ArticlesIndexResponse;
}
export type ArticlesShowMethod = 'GET';
export type ArticlesShowPath = '/articles/:id';
export interface ArticlesShowPathParams {
id: string;
}
export interface ArticlesShowRequestQuery {
include?: ArticleInclude;
}
export type ArticlesShowResponseBody = {
article: Article;
meta?: Record<string, unknown>;
};
export interface ArticlesShowRequest {
query: ArticlesShowRequestQuery;
}
export interface ArticlesShowResponse {
body: ArticlesShowResponseBody;
}
export interface ArticlesShow {
method: ArticlesShowMethod;
path: ArticlesShowPath;
pathParams: ArticlesShowPathParams;
request: ArticlesShowRequest;
response: ArticlesShowResponse;
}
export type ArticlesCreateMethod = 'POST';
export type ArticlesCreatePath = '/articles';
export interface ArticlesCreateRequestQuery {
include?: ArticleInclude;
}
export interface ArticlesCreateRequestBody {
article: ArticleCreatePayload;
}
export type ArticlesCreateResponseBody = {
article: Article;
meta?: Record<string, unknown>;
};
export interface ArticlesCreateRequest {
body: ArticlesCreateRequestBody;
query: ArticlesCreateRequestQuery;
}
export interface ArticlesCreateResponse {
body: ArticlesCreateResponseBody;
}
export type ArticlesCreateErrors = 422;
export interface ArticlesCreate {
errors: ArticlesCreateErrors;
method: ArticlesCreateMethod;
path: ArticlesCreatePath;
request: ArticlesCreateRequest;
response: ArticlesCreateResponse;
}
export type ArticlesUpdateMethod = 'PATCH';
export type ArticlesUpdatePath = '/articles/:id';
export interface ArticlesUpdatePathParams {
id: string;
}
export interface ArticlesUpdateRequestQuery {
include?: ArticleInclude;
}
export interface ArticlesUpdateRequestBody {
article: ArticleUpdatePayload;
}
export type ArticlesUpdateResponseBody = {
article: Article;
meta?: Record<string, unknown>;
};
export interface ArticlesUpdateRequest {
body: ArticlesUpdateRequestBody;
query: ArticlesUpdateRequestQuery;
}
export interface ArticlesUpdateResponse {
body: ArticlesUpdateResponseBody;
}
export type ArticlesUpdateErrors = 422;
export interface ArticlesUpdate {
errors: ArticlesUpdateErrors;
method: ArticlesUpdateMethod;
path: ArticlesUpdatePath;
pathParams: ArticlesUpdatePathParams;
request: ArticlesUpdateRequest;
response: ArticlesUpdateResponse;
}
export type ArticlesDestroyMethod = 'DELETE';
export type ArticlesDestroyPath = '/articles/:id';
export interface ArticlesDestroyPathParams {
id: string;
}
export interface ArticlesDestroyRequestQuery {
include?: ArticleInclude;
}
export interface ArticlesDestroyRequest {
query: ArticlesDestroyRequestQuery;
}
export interface ArticlesDestroy {
method: ArticlesDestroyMethod;
path: ArticlesDestroyPath;
pathParams: ArticlesDestroyPathParams;
request: ArticlesDestroyRequest;
}ts
export * from './articles';Sorbus
ts
import * as z from 'zod';
export const ErrorLayerSchema = z.enum(['contract', 'domain', 'http']);
export const SortDirectionSchema = z.enum(['asc', 'desc']);
export const DateFilterBetweenSchema = z.object({
from: z.iso.date().optional(),
to: z.iso.date().optional(),
});
export const ErrorIssueSchema = z.object({
code: z.string(),
detail: z.string(),
meta: z.record(z.string(), z.unknown()),
path: z.array(z.union([z.string(), z.number().int()])),
pointer: z.string(),
});
export const IntegerFilterBetweenSchema = z.object({
from: z.number().int().optional(),
to: z.number().int().optional(),
});
export const OffsetPaginationSchema = z.object({
current: z.number().int(),
items: z.number().int(),
next: z.number().int().nullable().optional(),
prev: z.number().int().nullable().optional(),
total: z.number().int(),
});
export const StringFilterSchema = z.object({
contains: z.string().optional(),
endsWith: z.string().optional(),
eq: z.string().optional(),
in: z.array(z.string()).optional(),
startsWith: z.string().optional(),
});
export const ErrorSchema = z.object({
issues: z.array(ErrorIssueSchema),
layer: ErrorLayerSchema,
});
export const NullableDateFilterSchema = z.object({
between: DateFilterBetweenSchema.optional(),
eq: z.iso.date().optional(),
gt: z.iso.date().optional(),
gte: z.iso.date().optional(),
in: z.array(z.iso.date()).optional(),
lt: z.iso.date().optional(),
lte: z.iso.date().optional(),
null: z.boolean().optional(),
});
export const NullableIntegerFilterSchema = z.object({
between: IntegerFilterBetweenSchema.optional(),
eq: z.number().int().optional(),
gt: z.number().int().optional(),
gte: z.number().int().optional(),
in: z.array(z.number().int()).optional(),
lt: z.number().int().optional(),
lte: z.number().int().optional(),
null: z.boolean().optional(),
});
export type ErrorLayer = 'contract' | 'domain' | 'http';
export type SortDirection = 'asc' | 'desc';
export interface DateFilterBetween {
from?: string;
to?: string;
}
export interface ErrorIssue {
code: string;
detail: string;
meta: Record<string, unknown>;
path: string | number[];
pointer: string;
}
export interface IntegerFilterBetween {
from?: number;
to?: number;
}
export interface OffsetPagination {
current: number;
items: number;
next?: number | null;
prev?: number | null;
total: number;
}
export interface StringFilter {
contains?: string;
endsWith?: string;
eq?: string;
in?: string[];
startsWith?: string;
}
export interface Error {
issues: ErrorIssue[];
layer: ErrorLayer;
}
export interface NullableDateFilter {
between?: DateFilterBetween;
eq?: string;
gt?: string;
gte?: string;
in?: string[];
lt?: string;
lte?: string;
null?: boolean;
}
export interface NullableIntegerFilter {
between?: IntegerFilterBetween;
eq?: number;
gt?: number;
gte?: number;
in?: number[];
lt?: number;
lte?: number;
null?: boolean;
}ts
import type { ArticlesOperationTree } from './endpoints';
import { createClientFactory } from 'sorbus';
import { contract } from './contract';
export interface Client {
articles: ArticlesOperationTree;
}
export const createClient = createClientFactory<Client>(contract);ts
import { ErrorSchema } from './api';
import { articles } from './endpoints';
export const contract = {
endpoints: {
articles,
},
error: ErrorSchema,
} as const;ts
import type {
NullableDateFilter,
NullableIntegerFilter,
SortDirection,
StringFilter,
} from '../api';
import type { Category, CategoryFilter } from './category';
import * as z from 'zod';
import {
NullableDateFilterSchema,
NullableIntegerFilterSchema,
SortDirectionSchema,
StringFilterSchema,
} from '../api';
import { CategoryFilterSchema, CategorySchema } from './category';
export const ArticleStatusSchema = z.enum(['archived', 'draft', 'published']);
export const ArticleFilterSchema: z.ZodType<ArticleFilter> = z.lazy(() =>
z.object({
AND: z.array(ArticleFilterSchema).optional(),
category: CategoryFilterSchema.optional(),
NOT: ArticleFilterSchema.optional(),
OR: z.array(ArticleFilterSchema).optional(),
publishedOn: z.union([z.iso.date(), NullableDateFilterSchema]).optional(),
status: ArticleStatusFilterSchema.optional(),
title: z.union([z.string(), StringFilterSchema]).optional(),
viewCount: z
.union([z.number().int(), NullableIntegerFilterSchema])
.optional(),
}),
);
export const ArticleCreatePayloadSchema = z.object({
body: z.string().nullable().default(null),
publishedOn: z.iso.date().nullable().default(null),
status: ArticleStatusSchema.default('draft'),
title: z.string(),
});
export const ArticleIncludeSchema = z.object({
category: z.boolean().optional(),
});
export const ArticlePageSchema = z.object({
number: z.number().int().min(1).optional(),
size: z.number().int().min(1).max(100).optional(),
});
export const ArticleSortSchema = z.object({
createdAt: SortDirectionSchema.optional(),
publishedOn: SortDirectionSchema.optional(),
status: SortDirectionSchema.optional(),
updatedAt: SortDirectionSchema.optional(),
viewCount: SortDirectionSchema.optional(),
});
export const ArticleStatusFilterSchema = z.union([
ArticleStatusSchema,
z
.object({ eq: ArticleStatusSchema, in: z.array(ArticleStatusSchema) })
.partial(),
]);
export const ArticleUpdatePayloadSchema = z.object({
body: z.string().nullable().optional(),
publishedOn: z.iso.date().nullable().optional(),
status: ArticleStatusSchema.optional(),
title: z.string().optional(),
});
export const ArticleSchema = z.object({
body: z.string().nullable(),
category: CategorySchema.nullable().optional(),
createdAt: z.iso.datetime(),
id: z.string(),
publishedOn: z.iso.date().nullable(),
rating: z.number().nullable(),
status: ArticleStatusSchema,
title: z.string(),
updatedAt: z.iso.datetime(),
viewCount: z.number().int().nullable(),
});
export type ArticleStatus = 'archived' | 'draft' | 'published';
export interface ArticleFilter {
AND?: ArticleFilter[];
category?: CategoryFilter;
NOT?: ArticleFilter;
OR?: ArticleFilter[];
publishedOn?: string | NullableDateFilter;
status?: ArticleStatusFilter;
title?: string | StringFilter;
viewCount?: number | NullableIntegerFilter;
}
export interface ArticleCreatePayload {
body?: string | null;
publishedOn?: string | null;
status?: ArticleStatus;
title: string;
}
export interface ArticleInclude {
category?: boolean;
}
export interface ArticlePage {
number?: number;
size?: number;
}
export interface ArticleSort {
createdAt?: SortDirection;
publishedOn?: SortDirection;
status?: SortDirection;
updatedAt?: SortDirection;
viewCount?: SortDirection;
}
export type ArticleStatusFilter =
| ArticleStatus
| { eq?: ArticleStatus; in?: ArticleStatus[] };
export interface ArticleUpdatePayload {
body?: string | null;
publishedOn?: string | null;
status?: ArticleStatus;
title?: string;
}
export interface Article {
body: string | null;
category?: Category | null;
createdAt: string;
id: string;
publishedOn: string | null;
rating: number | null;
status: ArticleStatus;
title: string;
updatedAt: string;
viewCount: number | null;
}ts
import type { StringFilter } from '../api';
import * as z from 'zod';
import { StringFilterSchema } from '../api';
export const CategoryFilterSchema: z.ZodType<CategoryFilter> = z.lazy(() =>
z.object({
AND: z.array(CategoryFilterSchema).optional(),
NOT: CategoryFilterSchema.optional(),
name: z.union([z.string(), StringFilterSchema]).optional(),
OR: z.array(CategoryFilterSchema).optional(),
}),
);
export const CategorySchema = z.object({
id: z.string(),
name: z.string(),
slug: z.string(),
});
export interface CategoryFilter {
AND?: CategoryFilter[];
NOT?: CategoryFilter;
name?: string | StringFilter;
OR?: CategoryFilter[];
}
export interface Category {
id: string;
name: string;
slug: string;
}ts
export * from './article';
export * from './category';ts
import type { Operation } from 'sorbus';
import type { OffsetPagination } from '../api';
import type {
Article,
ArticleCreatePayload,
ArticleFilter,
ArticleInclude,
ArticlePage,
ArticleSort,
ArticleUpdatePayload,
} from '../domains/article';
import * as z from 'zod';
import { OffsetPaginationSchema } from '../api';
import {
ArticleCreatePayloadSchema,
ArticleFilterSchema,
ArticleIncludeSchema,
ArticlePageSchema,
ArticleSchema,
ArticleSortSchema,
ArticleUpdatePayloadSchema,
} from '../domains/article';
export const ArticlesIndexRequestQuerySchema = z.object({
filter: z
.union([ArticleFilterSchema, z.array(ArticleFilterSchema)])
.optional(),
include: ArticleIncludeSchema.optional(),
page: ArticlePageSchema.optional(),
sort: z.union([ArticleSortSchema, z.array(ArticleSortSchema)]).optional(),
});
export const ArticlesIndexResponseBodySchema = z.object({
articles: z.array(ArticleSchema),
meta: z.record(z.string(), z.unknown()).optional(),
pagination: OffsetPaginationSchema,
});
export const ArticlesShowPathParamsSchema = z.object({ id: z.string() });
export const ArticlesShowRequestQuerySchema = z.object({
include: ArticleIncludeSchema.optional(),
});
export const ArticlesShowResponseBodySchema = z.object({
article: ArticleSchema,
meta: z.record(z.string(), z.unknown()).optional(),
});
export const ArticlesCreateRequestQuerySchema = z.object({
include: ArticleIncludeSchema.optional(),
});
export const ArticlesCreateRequestBodySchema = z.object({
article: ArticleCreatePayloadSchema,
});
export const ArticlesCreateResponseBodySchema = z.object({
article: ArticleSchema,
meta: z.record(z.string(), z.unknown()).optional(),
});
export const ArticlesUpdatePathParamsSchema = z.object({ id: z.string() });
export const ArticlesUpdateRequestQuerySchema = z.object({
include: ArticleIncludeSchema.optional(),
});
export const ArticlesUpdateRequestBodySchema = z.object({
article: ArticleUpdatePayloadSchema,
});
export const ArticlesUpdateResponseBodySchema = z.object({
article: ArticleSchema,
meta: z.record(z.string(), z.unknown()).optional(),
});
export const ArticlesDestroyPathParamsSchema = z.object({ id: z.string() });
export const ArticlesDestroyRequestQuerySchema = z.object({
include: ArticleIncludeSchema.optional(),
});
export type ArticlesIndexMethod = 'GET';
export type ArticlesIndexPath = '/articles';
export interface ArticlesIndexRequestQuery {
filter?: ArticleFilter | ArticleFilter[];
include?: ArticleInclude;
page?: ArticlePage;
sort?: ArticleSort | ArticleSort[];
}
export type ArticlesIndexResponseBody = {
articles: Article[];
meta?: Record<string, unknown>;
pagination: OffsetPagination;
};
export interface ArticlesIndexRequest {
query: ArticlesIndexRequestQuery;
}
export interface ArticlesIndexResponse {
body: ArticlesIndexResponseBody;
}
export interface ArticlesIndex {
method: ArticlesIndexMethod;
path: ArticlesIndexPath;
request: ArticlesIndexRequest;
response: ArticlesIndexResponse;
}
export type ArticlesShowMethod = 'GET';
export type ArticlesShowPath = '/articles/:id';
export interface ArticlesShowPathParams {
id: string;
}
export interface ArticlesShowRequestQuery {
include?: ArticleInclude;
}
export type ArticlesShowResponseBody = {
article: Article;
meta?: Record<string, unknown>;
};
export interface ArticlesShowRequest {
query: ArticlesShowRequestQuery;
}
export interface ArticlesShowResponse {
body: ArticlesShowResponseBody;
}
export interface ArticlesShow {
method: ArticlesShowMethod;
path: ArticlesShowPath;
pathParams: ArticlesShowPathParams;
request: ArticlesShowRequest;
response: ArticlesShowResponse;
}
export type ArticlesCreateMethod = 'POST';
export type ArticlesCreatePath = '/articles';
export interface ArticlesCreateRequestQuery {
include?: ArticleInclude;
}
export interface ArticlesCreateRequestBody {
article: ArticleCreatePayload;
}
export type ArticlesCreateResponseBody = {
article: Article;
meta?: Record<string, unknown>;
};
export interface ArticlesCreateRequest {
body: ArticlesCreateRequestBody;
query: ArticlesCreateRequestQuery;
}
export interface ArticlesCreateResponse {
body: ArticlesCreateResponseBody;
}
export type ArticlesCreateErrors = 422;
export interface ArticlesCreate {
errors: ArticlesCreateErrors;
method: ArticlesCreateMethod;
path: ArticlesCreatePath;
request: ArticlesCreateRequest;
response: ArticlesCreateResponse;
}
export type ArticlesUpdateMethod = 'PATCH';
export type ArticlesUpdatePath = '/articles/:id';
export interface ArticlesUpdatePathParams {
id: string;
}
export interface ArticlesUpdateRequestQuery {
include?: ArticleInclude;
}
export interface ArticlesUpdateRequestBody {
article: ArticleUpdatePayload;
}
export type ArticlesUpdateResponseBody = {
article: Article;
meta?: Record<string, unknown>;
};
export interface ArticlesUpdateRequest {
body: ArticlesUpdateRequestBody;
query: ArticlesUpdateRequestQuery;
}
export interface ArticlesUpdateResponse {
body: ArticlesUpdateResponseBody;
}
export type ArticlesUpdateErrors = 422;
export interface ArticlesUpdate {
errors: ArticlesUpdateErrors;
method: ArticlesUpdateMethod;
path: ArticlesUpdatePath;
pathParams: ArticlesUpdatePathParams;
request: ArticlesUpdateRequest;
response: ArticlesUpdateResponse;
}
export type ArticlesDestroyMethod = 'DELETE';
export type ArticlesDestroyPath = '/articles/:id';
export interface ArticlesDestroyPathParams {
id: string;
}
export interface ArticlesDestroyRequestQuery {
include?: ArticleInclude;
}
export interface ArticlesDestroyRequest {
query: ArticlesDestroyRequestQuery;
}
export interface ArticlesDestroy {
method: ArticlesDestroyMethod;
path: ArticlesDestroyPath;
pathParams: ArticlesDestroyPathParams;
request: ArticlesDestroyRequest;
}
export const articles = {
create: {
errors: [422],
method: 'POST',
path: '/articles',
request: {
body: ArticlesCreateRequestBodySchema,
query: ArticlesCreateRequestQuerySchema,
},
response: {
body: ArticlesCreateResponseBodySchema,
},
},
destroy: {
method: 'DELETE',
path: '/articles/:id',
pathParams: ArticlesDestroyPathParamsSchema,
request: {
query: ArticlesDestroyRequestQuerySchema,
},
},
index: {
method: 'GET',
path: '/articles',
request: {
query: ArticlesIndexRequestQuerySchema,
},
response: {
body: ArticlesIndexResponseBodySchema,
},
},
show: {
method: 'GET',
path: '/articles/:id',
pathParams: ArticlesShowPathParamsSchema,
request: {
query: ArticlesShowRequestQuerySchema,
},
response: {
body: ArticlesShowResponseBodySchema,
},
},
update: {
errors: [422],
method: 'PATCH',
path: '/articles/:id',
pathParams: ArticlesUpdatePathParamsSchema,
request: {
body: ArticlesUpdateRequestBodySchema,
query: ArticlesUpdateRequestQuerySchema,
},
response: {
body: ArticlesUpdateResponseBodySchema,
},
},
} as const;
export interface ArticlesOperationTree {
create: Operation<ArticlesCreate>;
destroy: Operation<ArticlesDestroy>;
index: Operation<ArticlesIndex>;
show: Operation<ArticlesShow>;
update: Operation<ArticlesUpdate>;
}ts
export * from './articles';