chore: add openapi

This commit is contained in:
Catalin Pit
2024-01-19 16:55:16 +02:00
parent 3b82ba57f3
commit b28a7f9702
6 changed files with 1533 additions and 4 deletions

View File

@ -0,0 +1,3 @@
'use client';
export { OpenApiDocsPage as default } from '@documenso/api/v1/api-documentation';

View File

@ -0,0 +1,7 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import { OpenAPIV1 } from '@documenso/api/v1/openapi';
export default function handler(req: NextApiRequest, res: NextApiResponse) {
res.status(200).json(OpenAPIV1);
}

1497
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -19,10 +19,11 @@
"@documenso/prisma": "*", "@documenso/prisma": "*",
"@ts-rest/core": "^3.30.5", "@ts-rest/core": "^3.30.5",
"@ts-rest/next": "^3.30.5", "@ts-rest/next": "^3.30.5",
"@ts-rest/open-api": "^3.33.0",
"luxon": "^3.4.0", "luxon": "^3.4.0",
"superjson": "^1.13.1", "superjson": "^1.13.1",
"swagger-ui-react": "^5.11.0",
"ts-pattern": "^5.0.5", "ts-pattern": "^5.0.5",
"zod": "^3.22.4" "zod": "^3.22.4"
}, }
"devDependencies": {}
} }

View File

@ -0,0 +1,8 @@
import SwaggerUI from 'swagger-ui-react';
import 'swagger-ui-react/swagger-ui.css';
import { OpenAPIV1 } from '@documenso/api/v1/openapi';
export const OpenApiDocsPage = () => {
return <SwaggerUI spec={OpenAPIV1} displayOperationId={true} />;
};

View File

@ -0,0 +1,17 @@
import { generateOpenApi } from '@ts-rest/open-api';
import { ApiContractV1 } from './contract';
export const OpenAPIV1 = generateOpenApi(
ApiContractV1,
{
info: {
title: 'Documenso API',
version: '1.0.0',
description: 'Documenso API',
},
},
{
setOperationId: true,
},
);