Generate explicit OpenAPI contracts for API routes

This commit is contained in:
Mike Cao committed 2026-09-01 15:09:10 -07:00
1 parent cc5d71d39f
commit e1a4934038
177 files changed
+50955 -1460

No files matched your search

+141
View File
@@ -0,0 +1,141 @@
// Generated by `pnpm openapi:contracts`. Do not edit directly.
import type { ZodOpenApiOperationObject } from 'zod-openapi';
import { defineOperation } from '@/openapi/operation';
const operation1 = defineOperation({
method: 'get',
path: '/api/me',
audience: 'public',
auth: 'bearer',
operation: {
operationId: 'getMe',
summary: 'Get me',
description:
'Get me. The request and response models are derived from the validated route contract.',
tags: ['Account'],
responses: {
'200': {
description: 'The operation completed successfully.',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
user: {
type: 'object',
properties: {
id: {
type: 'string',
},
username: {
type: 'string',
},
role: {
type: 'string',
},
isAdmin: {
type: 'boolean',
},
},
required: ['id', 'username', 'role', 'isAdmin'],
},
shareToken: {
type: 'object',
properties: {
shareType: {
type: 'number',
},
websiteId: {
type: 'string',
},
websiteIds: {
type: 'array',
items: {
type: 'string',
},
},
boardId: {
type: 'string',
},
pixelId: {
type: 'string',
},
pixelIds: {
type: 'array',
items: {
type: 'string',
},
},
linkId: {
type: 'string',
},
linkIds: {
type: 'array',
items: {
type: 'string',
},
},
parameters: {
type: 'object',
properties: {
allowFilter: {
type: 'boolean',
},
theme: {
anyOf: [
{
const: 'light',
},
{
const: 'dark',
},
],
},
},
additionalProperties: {
anyOf: [
{
const: false,
},
{
const: true,
},
{
const: 'light',
},
{
const: 'dark',
},
],
},
},
},
},
},
},
},
},
},
'401': {
description: 'Unauthorized.',
content: {
'application/json': {
example: {
error: {
message: 'Unauthorized.',
code: 'unauthorized',
status: 401,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
},
} as ZodOpenApiOperationObject,
});
export const operations = [operation1] as const;
@@ -0,0 +1,102 @@
// Generated by `pnpm openapi:contracts`. Do not edit directly.
import type { ZodOpenApiOperationObject } from 'zod-openapi';
import { defineOperation } from '@/openapi/operation';
const operation1 = defineOperation({
method: 'post',
path: '/api/me/password',
audience: 'public',
auth: 'bearer',
operation: {
operationId: 'postMePassword',
summary: 'Create or update me password',
description:
'Create or update me password. The request and response models are derived from the validated route contract.',
tags: ['Account'],
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
currentPassword: {
type: 'string',
},
newPassword: {
type: 'string',
minLength: 8,
},
},
required: ['currentPassword', 'newPassword'],
},
},
},
},
responses: {
'200': {
description: 'The operation completed successfully.',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
id: {
type: 'string',
},
createdAt: {
type: 'string',
format: 'date-time',
},
username: {
type: 'string',
},
role: {
type: 'string',
},
},
required: ['id', 'createdAt', 'username', 'role'],
},
},
},
},
'400': {
description: 'Bad request.',
content: {
'application/json': {
example: {
error: {
message: 'Bad request.',
code: 'bad-request',
status: 400,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
'401': {
description: 'Unauthorized.',
content: {
'application/json': {
example: {
error: {
message: 'Unauthorized.',
code: 'unauthorized',
status: 401,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
},
} as ZodOpenApiOperationObject,
});
export const operations = [operation1] as const;
+2 -1
View File
@@ -1,5 +1,6 @@
import { parseRequest } from '@/lib/request';
import { json } from '@/lib/response';
import type { Auth } from '@/lib/types';
export async function GET(request: Request) {
const { auth, error } = await parseRequest(request);
@@ -8,5 +9,5 @@ export async function GET(request: Request) {
return error();
}
return json(auth);
return json(auth as Auth);
}
+181
View File
@@ -0,0 +1,181 @@
// Generated by `pnpm openapi:contracts`. Do not edit directly.
import type { ZodOpenApiOperationObject } from 'zod-openapi';
import { defineOperation } from '@/openapi/operation';
const operation1 = defineOperation({
method: 'get',
path: '/api/me/teams',
audience: 'public',
auth: 'bearer',
operation: {
operationId: 'getMeTeams',
summary: 'Get me teams',
description:
'Get me teams. The request and response models are derived from the validated route contract.',
tags: ['Account'],
parameters: [
{
name: 'page',
in: 'query',
required: false,
schema: {
type: 'integer',
minimum: 1,
},
},
{
name: 'pageSize',
in: 'query',
required: false,
schema: {
type: 'integer',
minimum: 1,
},
},
{
name: 'maxResults',
in: 'query',
required: false,
schema: {
type: 'integer',
minimum: 1,
},
},
{
name: 'orderBy',
in: 'query',
required: false,
schema: {
type: 'string',
},
},
{
name: 'sortDescending',
in: 'query',
required: false,
schema: {
type: 'string',
enum: ['true', 'false'],
},
},
],
responses: {
'200': {
description: 'The operation completed successfully.',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
data: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
},
createdAt: {
type: 'string',
format: 'date-time',
},
updatedAt: {
type: 'string',
format: 'date-time',
},
logoUrl: {
type: 'string',
},
twoFactorRequired: {
type: 'boolean',
},
deletedAt: {
type: 'string',
format: 'date-time',
},
name: {
type: 'string',
},
accessCode: {
type: 'string',
},
},
required: [
'id',
'createdAt',
'updatedAt',
'logoUrl',
'twoFactorRequired',
'deletedAt',
'name',
'accessCode',
],
},
},
count: {
type: 'number',
},
page: {
type: 'number',
},
pageSize: {
type: 'number',
},
orderBy: {
type: 'string',
},
sortDescending: {
type: 'boolean',
},
search: {
type: 'string',
},
isCapped: {
type: 'boolean',
},
},
required: ['data', 'count', 'page', 'pageSize'],
},
},
},
},
'400': {
description: 'Bad request.',
content: {
'application/json': {
example: {
error: {
message: 'Bad request.',
code: 'bad-request',
status: 400,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
'401': {
description: 'Unauthorized.',
content: {
'application/json': {
example: {
error: {
message: 'Unauthorized.',
code: 'unauthorized',
status: 401,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
},
} as ZodOpenApiOperationObject,
});
export const operations = [operation1] as const;
@@ -0,0 +1,316 @@
// Generated by `pnpm openapi:contracts`. Do not edit directly.
import type { ZodOpenApiOperationObject } from 'zod-openapi';
import { defineOperation } from '@/openapi/operation';
const operation1 = defineOperation({
method: 'get',
path: '/api/me/websites',
audience: 'public',
auth: 'bearer',
operation: {
operationId: 'getMeWebsites',
summary: 'Get me websites',
description:
'Get me websites. The request and response models are derived from the validated route contract.',
tags: ['Account'],
parameters: [
{
name: 'page',
in: 'query',
required: false,
schema: {
type: 'integer',
minimum: 1,
},
},
{
name: 'pageSize',
in: 'query',
required: false,
schema: {
type: 'integer',
minimum: 1,
},
},
{
name: 'maxResults',
in: 'query',
required: false,
schema: {
type: 'integer',
minimum: 1,
},
},
{
name: 'orderBy',
in: 'query',
required: false,
schema: {
type: 'string',
},
},
{
name: 'sortDescending',
in: 'query',
required: false,
schema: {
type: 'string',
enum: ['true', 'false'],
},
},
{
name: 'includeTeams',
in: 'query',
required: false,
schema: {
type: 'string',
},
},
],
responses: {
'200': {
description: 'The operation completed successfully.',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
data: {
type: 'array',
items: {
allOf: [
{
type: 'object',
properties: {
id: {
type: 'string',
},
userId: {
type: 'string',
},
createdAt: {
type: 'string',
format: 'date-time',
},
updatedAt: {
type: 'string',
format: 'date-time',
},
deletedAt: {
type: 'string',
format: 'date-time',
},
createdBy: {
type: 'string',
},
name: {
type: 'string',
},
domain: {
type: 'string',
},
resetAt: {
type: 'string',
format: 'date-time',
},
teamId: {
type: 'string',
},
recorderEnabled: {
type: 'boolean',
},
replayConfig: {
anyOf: [
{
type: 'string',
},
{
type: 'number',
},
{
const: false,
},
{
const: true,
},
{
type: 'object',
properties: {},
additionalProperties: {
anyOf: [
{
type: 'string',
},
{
type: 'number',
},
{
const: false,
},
{
const: true,
},
{},
{
type: 'object',
properties: {
length: {
type: 'number',
},
},
required: ['length'],
},
],
},
},
{
type: 'object',
properties: {
length: {
type: 'number',
},
},
required: ['length'],
},
],
},
},
required: [
'id',
'userId',
'createdAt',
'updatedAt',
'deletedAt',
'createdBy',
'name',
'domain',
'resetAt',
'teamId',
'recorderEnabled',
'replayConfig',
],
},
{
type: 'object',
properties: {
shareId: {
type: 'string',
},
user: {
type: 'object',
properties: {
id: {
type: 'string',
},
username: {
type: 'string',
},
},
required: ['id', 'username'],
},
createUser: {
type: 'object',
properties: {
id: {
type: 'string',
},
username: {
type: 'string',
},
},
required: ['id', 'username'],
},
team: {
type: 'object',
properties: {
members: {
type: 'array',
items: {
type: 'object',
properties: {
userId: {
type: 'string',
},
role: {
type: 'string',
},
},
required: ['userId', 'role'],
},
},
},
required: ['members'],
},
},
required: ['shareId'],
},
],
},
},
count: {
type: 'number',
},
page: {
type: 'number',
},
pageSize: {
type: 'number',
},
orderBy: {
type: 'string',
},
sortDescending: {
type: 'boolean',
},
search: {
type: 'string',
},
isCapped: {
type: 'boolean',
},
},
required: ['data', 'count', 'page', 'pageSize'],
},
},
},
},
'400': {
description: 'Bad request.',
content: {
'application/json': {
example: {
error: {
message: 'Bad request.',
code: 'bad-request',
status: 400,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
'401': {
description: 'Unauthorized.',
content: {
'application/json': {
example: {
error: {
message: 'Unauthorized.',
code: 'unauthorized',
status: 401,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
},
} as ZodOpenApiOperationObject,
});
export const operations = [operation1] as const;