fastify-xswagger
Route-scoped Swagger documentation with access control.
fastify-xswagger
Route-scoped Swagger/OpenAPI documentation for Fastify with built-in access control. Generates separate Swagger UIs for public and internal APIs.
Quick Start
await fastify.register(xSwagger, {
public: {
path: '/docs',
title: 'Public API',
description: 'Customer-facing API documentation',
},
internal: {
path: '/internal/docs',
title: 'Internal API',
requireRole: 'admin',
},
})
Route Tagging
fastify.post('/users', {
schema: {
tags: ['users'],
summary: 'Create user',
body: { $ref: 'CreateUserSchema#' },
response: { 200: { $ref: 'UserSchema#' } },
}
}, handler)
AI Context
package: "@xenterprises/fastify-xswagger"
use-when: API documentation, OpenAPI spec generation
scope: route-scoped — can expose different docs to different audiences
ui: Swagger UI at configured paths
openapi: 3.1 spec auto-generated from route schemas
