fastify-xswagger
fastify.xswagger.config
Read-only config summary exposed after plugin registration.
fastify.xswagger.config
A read-only object available after plugin registration that summarizes the resolved plugin configuration. Useful for logging, health-check endpoints, or conditional behavior based on environment. Auth credentials are never exposed.
Signature
fastify.xswagger.config: {
docsPath: string;
disableInProduction: boolean | 'public';
docCount: number;
hasAuth: boolean;
environment: 'production' | 'development';
}
Properties
| Property | Type | Description |
|---|---|---|
docsPath | string | The base docs UI path (e.g. '/documentation') |
disableInProduction | boolean | 'public' | The resolved disableInProduction value |
docCount | number | Total number of doc configs passed at registration |
hasAuth | boolean | true if auth credentials were provided |
environment | string | 'production' when NODE_ENV=production, otherwise 'development' |
Examples
Log config on startup
await fastify.register(xSwagger, {
docs: [
{ prefix: "/api", access: "public", title: "API" },
{ prefix: "/admin", access: "private", title: "Admin" },
],
auth: { username: process.env.DOCS_USER, password: process.env.DOCS_PASSWORD },
});
fastify.log.info(fastify.xswagger.config, "xSwagger config");
// {
// docsPath: '/documentation',
// disableInProduction: false,
// docCount: 2,
// hasAuth: true,
// environment: 'development'
// }
Health-check endpoint
fastify.get("/health/docs", async () => {
const { docCount, environment, hasAuth } = fastify.xswagger.config;
return {
docCount,
environment,
authEnabled: hasAuth,
};
});
See also
- docs[key].spec() — Per-doc instance properties and live spec accessor
- fastify-xswagger overview — Plugin setup and options
AI Context
package: "@xenterprises/fastify-xswagger"
accessor: fastify.xswagger.config
use-when: Inspect resolved plugin configuration at runtime — log the active docsPath, docCount, auth status, and environment without exposing credentials
returns: { docsPath, disableInProduction, docCount, hasAuth, environment }
