@ts-kizuna/openapi
v1.64.1
Published
OpenAPI 3.1 generation for ts-kizuna contracts
Readme
@ts-kizuna/openapi
@ts-kizuna/openapi generates an OpenAPI 3.1.0 document from your contract, and serves it with a reference UI on any adapter.
Installation
pnpm add @ts-kizuna/openapiUsage
Declare the plugin on k.contract:
import { openApiPlugin } from '@ts-kizuna/openapi';
import { k } from './k';
import { routes } from './routes';
export const contract = k.contract({
routes,
plugins: {
openApi: openApiPlugin({
info: {
title: 'My API',
version: '1.0.0',
},
}),
},
});Then pass its server half to server.api, where the generator lives:
import { openApiPluginServer } from '@ts-kizuna/openapi/server';
export const api = server.api({
router,
plugins: {
openApi: openApiPluginServer(),
},
});