| 6 | * @returns {Promise<void>} - A Promise that resolves once Swagger is successfully initialized |
| 7 | */ |
| 8 | export default async function initSwagger(server: FastifyInstance) { |
| 9 | // eslint-disable-next-line @typescript-eslint/no-var-requires |
| 10 | await server.register(require("@fastify/swagger"), { |
| 11 | openapi: { |
| 12 | info: { |
| 13 | title: "Test swagger", |
| 14 | description: "testing the fastify swagger api", |
| 15 | version: "0.1.0", |
| 16 | }, |
| 17 | servers: [ |
| 18 | { |
| 19 | url: "http://localhost:8000", |
| 20 | }, |
| 21 | ], |
| 22 | components: { |
| 23 | securitySchemes: { |
| 24 | apiKey: { |
| 25 | type: "apiKey", |
| 26 | name: "apiKey", |
| 27 | in: "header", |
| 28 | }, |
| 29 | }, |
| 30 | }, |
| 31 | }, |
| 32 | }); |
| 33 | // eslint-disable-next-line @typescript-eslint/no-var-requires |
| 34 | await server.register(require("@fastify/swagger-ui"), { |
| 35 | routePrefix: "/docs", |
| 36 | }); |
| 37 | } |