import swagger from "@fastify/swagger"; import swaggerUi from "@fastify/swagger-ui"; import fp from "fastify-plugin"; import { jsonSchemaTransform, jsonSchemaTransformObject, } from "fastify-type-provider-zod"; export const swaggerPlugin = fp( async (app) => { await app.register(swagger, { transform: jsonSchemaTransform, transformObject: jsonSchemaTransformObject, openapi: { info: { title: "{{PROJECT_DISPLAY_NAME}} API", description: "API documentation generated by LaunchStack CLI.", version: "0.1.0", }, servers: [ { url: `http://localhost:${app.config.port}`, description: "Local development", }, ], tags: [ { name: "System", description: "Health and operational endpoints", }, { name: "Authentication", description: "User authentication and token lifecycle", }, ], components: { securitySchemes: { bearerAuth: { type: "http", scheme: "bearer", bearerFormat: "JWT", }, }, }, }, }); await app.register(swaggerUi, { routePrefix: "/docs", uiConfig: { docExpansion: "list", deepLinking: true, displayRequestDuration: true, }, staticCSP: true, transformStaticCSP: (header) => header, }); }, { name: "swagger", dependencies: ["config"], }, );