import { FastifyPlugin } from 'fastify'; import * as SwaggerSchema from 'swagger-schema-official'; interface FastifySwaggerOptions { mode?: 'static' | 'dynamic'; /** * Overwrite the swagger url end-point * @default /documentation */ routePrefix?: string; /** * To expose the documentation api * @default false */ exposeRoute?: boolean; } interface FastifyDynamicSwaggerOptions extends FastifySwaggerOptions { mode?: 'dynamic'; swagger?: Partial; /** * Overwrite the route schema */ transform?: Function; } interface StaticPathSpec { path: string; postProcessor?: (spec: SwaggerSchema.Spec) => SwaggerSchema.Spec; baseDir: string; } interface StaticDocumentSpec { document: string; } interface FastifyStaticSwaggerOptions extends FastifySwaggerOptions { mode: 'static'; specification: StaticPathSpec | StaticDocumentSpec; } declare module 'fastify' { interface FastifyInstance { swagger: ( opts?: { yaml?: boolean; } ) => SwaggerSchema.Spec; } interface FastifySchema { hide?: boolean; tags?: string[]; description?: string; summary?: string; consumes?: string[]; security?: Array<{ [securityLabel: string]: string[] }>; } } type SwaggerOptions = (FastifyStaticSwaggerOptions | FastifyDynamicSwaggerOptions) declare const fastifySwagger: FastifyPlugin export default fastifySwagger;