Plugin options
An IPlugin instance
app.register(OpenApiPlugin({
title: 'My API',
version: '1.0.0',
endpoint: '/docs',
specEndpoint: '/openapi.json',
securitySchemes: {
bearerAuth: { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
},
security: [{ bearerAuth: [] }],
exclude: ['/health', '/live', '/ready', '/metrics'],
}));
Creates an OpenAPI plugin that auto-generates OpenAPI 3.1 documentation from registered routes and serves it (with optional Swagger UI).
The plugin:
IOpenApiServiceunderCAPABILITIES.OPENAPICAPABILITIES.OPENAPI_SCHEMAcontributions at registrationspecEndpoint(default/openapi.json)endpoint(default/docs) whenswagger !== falseOpenApiGeneratorOptions.excludeDeclaring
securitySchemesis what gives Swagger UI its Authorize button. Pair it withsecurityto state that operations require authentication by default; an individual route opts out withschema: { security: [] }.