Cursor Pagination
Cursor-based pagination for navigating large datasets
API Definition
config/apis/grumpy_panda.rb
rb
# frozen_string_literal: true
Apiwork::API.define '/grumpy_panda' do
key_format :camel
export :openapi
export :typescript
export :zod
resources :activities
endModels
app/models/grumpy_panda/activity.rb
rb
# frozen_string_literal: true
module GrumpyPanda
class Activity < ApplicationRecord
validates :action, presence: true
end
endDatabase Table
| Column | Type | Nullable | Default |
|---|---|---|---|
| id | string | ||
| action | string | ||
| created_at | datetime | ||
| occurred_at | datetime | ✓ | |
| updated_at | datetime |
Representations
app/representations/grumpy_panda/activity_representation.rb
rb
# frozen_string_literal: true
module GrumpyPanda
class ActivityRepresentation < Apiwork::Representation::Base
adapter do
pagination do
strategy :cursor
default_size 3
end
end
attribute :id
attribute :action, writable: true
attribute :occurred_at, writable: true
attribute :created_at
attribute :updated_at
end
endContracts
app/contracts/grumpy_panda/activity_contract.rb
rb
# frozen_string_literal: true
module GrumpyPanda
class ActivityContract < Apiwork::Contract::Base
representation ActivityRepresentation
end
endControllers
app/controllers/grumpy_panda/activities_controller.rb
rb
# frozen_string_literal: true
module GrumpyPanda
class ActivitiesController < ApplicationController
before_action :set_activity, only: %i[show update destroy]
def index
activities = Activity.all
expose activities
end
def show
expose activity
end
def create
activity = Activity.create(contract.body[:activity])
expose activity
end
def update
activity.update(contract.body[:activity])
expose activity
end
def destroy
activity.destroy
expose activity
end
private
attr_reader :activity
def set_activity
@activity = Activity.find(params[:id])
end
end
endRequest Examples
First page
Request
http
GET /grumpy_panda/activitiesResponse 200
json
{
"activities": [
{
"id": "05601e34-4e5e-5293-a94c-d7f265d247b4",
"action": "user.logout",
"occurredAt": "2024-01-01T11:00:00.000Z",
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
},
{
"id": "28fab1f1-3992-5d5c-9d68-d136bc923c6e",
"action": "user.login",
"occurredAt": "2024-01-01T10:00:00.000Z",
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
},
{
"id": "4c39275f-ec14-5a37-858d-84eb6899b55d",
"action": "post.delete",
"occurredAt": "2024-01-01T14:00:00.000Z",
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
}
],
"pagination": {
"next": "eyJpZCI6IjRjMzkyNzVmLWVjMTQtNWEzNy04NThkLTg0ZWI2ODk5YjU1ZCJ9",
"prev": null
}
}Next page
Request
http
GET /grumpy_panda/activities?page[after]=eyJpZCI6IjRjMzkyNzVmLWVjMTQtNWEzNy04NThkLTg0ZWI2ODk5YjU1ZCJ9Response 200
json
{
"activities": [
{
"id": "941cf71e-f960-5659-8955-cdd06fb62148",
"action": "post.create",
"occurredAt": "2024-01-01T12:00:00.000Z",
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
},
{
"id": "d7d2baf6-242e-5a3b-8e5f-258913655538",
"action": "post.update",
"occurredAt": "2024-01-01T13:00:00.000Z",
"createdAt": "2024-01-01T12:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
}
],
"pagination": {
"next": null,
"prev": "eyJpZCI6Ijk0MWNmNzFlLWY5NjAtNTY1OS04OTU1LWNkZDA2ZmI2MjE0OCJ9"
}
}Generated Output
Introspection
json
{
"base_path": "/grumpy_panda",
"enums": {
"layer": {
"deprecated": false,
"description": null,
"example": null,
"values": [
"http",
"contract",
"domain"
]
}
},
"error_codes": {
"unprocessable_entity": {
"description": "Unprocessable Entity",
"status": 422
}
},
"info": null,
"resources": {
"activities": {
"actions": {
"index": {
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/activities",
"raises": [],
"request": {
"body": {},
"query": {
"page": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "reference",
"reference": "activity_page"
}
}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "union",
"discriminator": null,
"variants": [
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "activity_index_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": null,
"tags": []
},
"show": {
"deprecated": false,
"description": null,
"method": "get",
"operation_id": null,
"path": "/activities/: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": "activity_show_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": null,
"tags": []
},
"create": {
"deprecated": false,
"description": null,
"method": "post",
"operation_id": null,
"path": "/activities",
"raises": [
"unprocessable_entity"
],
"request": {
"body": {
"activity": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "activity_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": "activity_create_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": null,
"tags": []
},
"update": {
"deprecated": false,
"description": null,
"method": "patch",
"operation_id": null,
"path": "/activities/:id",
"raises": [
"unprocessable_entity"
],
"request": {
"body": {
"activity": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "activity_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": "activity_update_success_response_body"
},
{
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "error_response_body"
}
]
},
"no_content": false
},
"summary": null,
"tags": []
},
"destroy": {
"deprecated": false,
"description": null,
"method": "delete",
"operation_id": null,
"path": "/activities/:id",
"raises": [],
"request": {
"body": {},
"query": {}
},
"response": {
"body": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": null
},
"no_content": true
},
"summary": null,
"tags": []
}
},
"identifier": "activities",
"parent_identifiers": [],
"path": "activities",
"resources": {}
}
},
"types": {
"activity": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"action": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"created_at": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "datetime"
},
"id": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"occurred_at": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": false,
"type": "datetime"
},
"updated_at": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "datetime"
}
},
"type": "object",
"variants": []
},
"activity_create_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"action": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"occurred_at": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "datetime"
}
},
"type": "object",
"variants": []
},
"activity_create_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"activity": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "activity"
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
}
},
"type": "object",
"variants": []
},
"activity_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": "cursor_pagination"
},
"activities": {
"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": "activity"
},
"shape": {}
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
}
},
"type": "object",
"variants": []
},
"activity_page": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"after": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"before": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"size": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "integer",
"format": null,
"max": 100,
"min": 1
}
},
"type": "object",
"variants": []
},
"activity_show_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"activity": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "activity"
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
}
},
"type": "object",
"variants": []
},
"activity_update_payload": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"action": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"occurred_at": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "datetime"
}
},
"type": "object",
"variants": []
},
"activity_update_success_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"activity": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "activity"
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": true,
"type": "object",
"partial": false,
"shape": {}
}
},
"type": "object",
"variants": []
},
"cursor_pagination": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"next": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
},
"prev": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": true,
"optional": true,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
},
"error": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"issues": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "reference",
"reference": "issue"
},
"shape": {}
},
"layer": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "reference",
"reference": "layer"
}
},
"type": "object",
"variants": []
},
"error_response_body": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [
"error"
],
"shape": {},
"type": "object",
"variants": []
},
"issue": {
"deprecated": false,
"description": null,
"discriminator": null,
"example": null,
"extends": [],
"shape": {
"code": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"detail": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
},
"meta": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "object",
"partial": false,
"shape": {}
},
"path": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "array",
"max": null,
"min": null,
"of": {
"default": null,
"deprecated": null,
"description": null,
"example": null,
"nullable": null,
"optional": null,
"type": "string",
"format": null,
"max": null,
"min": null
},
"shape": {}
},
"pointer": {
"default": null,
"deprecated": false,
"description": null,
"example": null,
"nullable": false,
"optional": false,
"type": "string",
"format": null,
"max": null,
"min": null
}
},
"type": "object",
"variants": []
}
}
}TypeScript
ts
export interface ActivitiesCreateRequest {
body: ActivitiesCreateRequestBody;
}
export interface ActivitiesCreateRequestBody {
activity: ActivityCreatePayload;
}
export interface ActivitiesCreateResponse {
body: ActivitiesCreateResponseBody;
}
export type ActivitiesCreateResponseBody = ActivityCreateSuccessResponseBody | ErrorResponseBody;
export type ActivitiesDestroyResponse = never;
export interface ActivitiesIndexRequest {
query: ActivitiesIndexRequestQuery;
}
export interface ActivitiesIndexRequestQuery {
page?: ActivityPage;
}
export interface ActivitiesIndexResponse {
body: ActivitiesIndexResponseBody;
}
export type ActivitiesIndexResponseBody = ActivityIndexSuccessResponseBody | ErrorResponseBody;
export interface ActivitiesShowResponse {
body: ActivitiesShowResponseBody;
}
export type ActivitiesShowResponseBody = ActivityShowSuccessResponseBody | ErrorResponseBody;
export interface ActivitiesUpdateRequest {
body: ActivitiesUpdateRequestBody;
}
export interface ActivitiesUpdateRequestBody {
activity: ActivityUpdatePayload;
}
export interface ActivitiesUpdateResponse {
body: ActivitiesUpdateResponseBody;
}
export type ActivitiesUpdateResponseBody = ActivityUpdateSuccessResponseBody | ErrorResponseBody;
export interface Activity {
action: string;
createdAt: string;
id: string;
occurredAt: null | string;
updatedAt: string;
}
export interface ActivityCreatePayload {
action: string;
occurredAt?: null | string;
}
export interface ActivityCreateSuccessResponseBody {
activity: Activity;
meta?: Record<string, unknown>;
}
export interface ActivityIndexSuccessResponseBody {
activities: Activity[];
meta?: Record<string, unknown>;
pagination: CursorPagination;
}
export interface ActivityPage {
after?: string;
before?: string;
size?: number;
}
export interface ActivityShowSuccessResponseBody {
activity: Activity;
meta?: Record<string, unknown>;
}
export interface ActivityUpdatePayload {
action?: string;
occurredAt?: null | string;
}
export interface ActivityUpdateSuccessResponseBody {
activity: Activity;
meta?: Record<string, unknown>;
}
export interface CursorPagination {
next?: null | string;
prev?: null | string;
}
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';Zod
ts
import { z } from 'zod';
export const LayerSchema = z.enum(['contract', 'domain', 'http']);
export const ActivitySchema = z.object({
action: z.string(),
createdAt: z.iso.datetime(),
id: z.string(),
occurredAt: z.iso.datetime().nullable(),
updatedAt: z.iso.datetime()
});
export const ActivityCreatePayloadSchema = z.object({
action: z.string(),
occurredAt: z.iso.datetime().nullable().optional()
});
export const ActivityPageSchema = z.object({
after: z.string().optional(),
before: z.string().optional(),
size: z.number().int().min(1).max(100).optional()
});
export const ActivityUpdatePayloadSchema = z.object({
action: z.string().optional(),
occurredAt: z.iso.datetime().nullable().optional()
});
export const CursorPaginationSchema = z.object({
next: z.string().nullable().optional(),
prev: z.string().nullable().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 ActivityCreateSuccessResponseBodySchema = z.object({
activity: ActivitySchema,
meta: z.record(z.string(), z.unknown()).optional()
});
export const ActivityIndexSuccessResponseBodySchema = z.object({
activities: z.array(ActivitySchema),
meta: z.record(z.string(), z.unknown()).optional(),
pagination: CursorPaginationSchema
});
export const ActivityShowSuccessResponseBodySchema = z.object({
activity: ActivitySchema,
meta: z.record(z.string(), z.unknown()).optional()
});
export const ActivityUpdateSuccessResponseBodySchema = z.object({
activity: ActivitySchema,
meta: z.record(z.string(), z.unknown()).optional()
});
export const ErrorSchema = z.object({
issues: z.array(IssueSchema),
layer: LayerSchema
});
export const ErrorResponseBodySchema = ErrorSchema;
export const ActivitiesIndexRequestQuerySchema = z.object({
page: ActivityPageSchema.optional()
});
export const ActivitiesIndexRequestSchema = z.object({
query: ActivitiesIndexRequestQuerySchema
});
export const ActivitiesIndexResponseBodySchema = z.union([ActivityIndexSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const ActivitiesIndexResponseSchema = z.object({
body: ActivitiesIndexResponseBodySchema
});
export const ActivitiesShowResponseBodySchema = z.union([ActivityShowSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const ActivitiesShowResponseSchema = z.object({
body: ActivitiesShowResponseBodySchema
});
export const ActivitiesCreateRequestBodySchema = z.object({
activity: ActivityCreatePayloadSchema
});
export const ActivitiesCreateRequestSchema = z.object({
body: ActivitiesCreateRequestBodySchema
});
export const ActivitiesCreateResponseBodySchema = z.union([ActivityCreateSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const ActivitiesCreateResponseSchema = z.object({
body: ActivitiesCreateResponseBodySchema
});
export const ActivitiesUpdateRequestBodySchema = z.object({
activity: ActivityUpdatePayloadSchema
});
export const ActivitiesUpdateRequestSchema = z.object({
body: ActivitiesUpdateRequestBodySchema
});
export const ActivitiesUpdateResponseBodySchema = z.union([ActivityUpdateSuccessResponseBodySchema, ErrorResponseBodySchema]);
export const ActivitiesUpdateResponseSchema = z.object({
body: ActivitiesUpdateResponseBodySchema
});
export const ActivitiesDestroyResponseSchema = z.never();
export interface ActivitiesCreateRequest {
body: ActivitiesCreateRequestBody;
}
export interface ActivitiesCreateRequestBody {
activity: ActivityCreatePayload;
}
export interface ActivitiesCreateResponse {
body: ActivitiesCreateResponseBody;
}
export type ActivitiesCreateResponseBody = ActivityCreateSuccessResponseBody | ErrorResponseBody;
export type ActivitiesDestroyResponse = never;
export interface ActivitiesIndexRequest {
query: ActivitiesIndexRequestQuery;
}
export interface ActivitiesIndexRequestQuery {
page?: ActivityPage;
}
export interface ActivitiesIndexResponse {
body: ActivitiesIndexResponseBody;
}
export type ActivitiesIndexResponseBody = ActivityIndexSuccessResponseBody | ErrorResponseBody;
export interface ActivitiesShowResponse {
body: ActivitiesShowResponseBody;
}
export type ActivitiesShowResponseBody = ActivityShowSuccessResponseBody | ErrorResponseBody;
export interface ActivitiesUpdateRequest {
body: ActivitiesUpdateRequestBody;
}
export interface ActivitiesUpdateRequestBody {
activity: ActivityUpdatePayload;
}
export interface ActivitiesUpdateResponse {
body: ActivitiesUpdateResponseBody;
}
export type ActivitiesUpdateResponseBody = ActivityUpdateSuccessResponseBody | ErrorResponseBody;
export interface Activity {
action: string;
createdAt: string;
id: string;
occurredAt: null | string;
updatedAt: string;
}
export interface ActivityCreatePayload {
action: string;
occurredAt?: null | string;
}
export interface ActivityCreateSuccessResponseBody {
activity: Activity;
meta?: Record<string, unknown>;
}
export interface ActivityIndexSuccessResponseBody {
activities: Activity[];
meta?: Record<string, unknown>;
pagination: CursorPagination;
}
export interface ActivityPage {
after?: string;
before?: string;
size?: number;
}
export interface ActivityShowSuccessResponseBody {
activity: Activity;
meta?: Record<string, unknown>;
}
export interface ActivityUpdatePayload {
action?: string;
occurredAt?: null | string;
}
export interface ActivityUpdateSuccessResponseBody {
activity: Activity;
meta?: Record<string, unknown>;
}
export interface CursorPagination {
next?: null | string;
prev?: null | string;
}
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';OpenAPI
yml
---
openapi: 3.1.0
info:
title: "/grumpy_panda"
version: 1.0.0
paths:
"/activities":
get:
operationId: activitiesIndex
parameters:
- in: query
name: page
required: false
schema:
"$ref": "#/components/schemas/activityPage"
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/activityIndexSuccessResponseBody"
description: Successful response
post:
operationId: activitiesCreate
requestBody:
content:
application/json:
schema:
properties:
activity:
"$ref": "#/components/schemas/activityCreatePayload"
type: object
required:
- activity
required: true
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/activityCreateSuccessResponseBody"
description: Successful response
'422':
description: Unprocessable Entity
content:
application/json:
schema:
"$ref": "#/components/schemas/errorResponseBody"
"/activities/{id}":
get:
operationId: activitiesShow
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/activityShowSuccessResponseBody"
description: Successful response
patch:
operationId: activitiesUpdate
parameters:
- in: path
name: id
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
activity:
"$ref": "#/components/schemas/activityUpdatePayload"
type: object
required:
- activity
required: true
responses:
'200':
content:
application/json:
schema:
"$ref": "#/components/schemas/activityUpdateSuccessResponseBody"
description: Successful response
'422':
description: Unprocessable Entity
content:
application/json:
schema:
"$ref": "#/components/schemas/errorResponseBody"
delete:
operationId: activitiesDestroy
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'204':
description: No content
components:
schemas:
activity:
properties:
action:
type: string
createdAt:
type: string
format: date-time
id:
type: string
occurredAt:
type:
- string
- 'null'
format: date-time
updatedAt:
type: string
format: date-time
type: object
required:
- action
- createdAt
- id
- occurredAt
- updatedAt
activityCreatePayload:
properties:
action:
type: string
occurredAt:
type:
- string
- 'null'
format: date-time
type: object
required:
- action
activityCreateSuccessResponseBody:
properties:
activity:
"$ref": "#/components/schemas/activity"
meta:
properties: {}
type: object
type: object
required:
- activity
activityIndexSuccessResponseBody:
properties:
pagination:
"$ref": "#/components/schemas/cursorPagination"
activities:
items:
"$ref": "#/components/schemas/activity"
type: array
meta:
properties: {}
type: object
type: object
required:
- pagination
- activities
activityPage:
properties:
after:
type: string
before:
type: string
size:
type: integer
minimum: 1
maximum: 100
type: object
activityShowSuccessResponseBody:
properties:
activity:
"$ref": "#/components/schemas/activity"
meta:
properties: {}
type: object
type: object
required:
- activity
activityUpdatePayload:
properties:
action:
type: string
occurredAt:
type:
- string
- 'null'
format: date-time
type: object
activityUpdateSuccessResponseBody:
properties:
activity:
"$ref": "#/components/schemas/activity"
meta:
properties: {}
type: object
type: object
required:
- activity
cursorPagination:
properties:
next:
type:
- string
- 'null'
prev:
type:
- string
- 'null'
type: object
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