X Enterprises
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

PropertyTypeDescription
docsPathstringThe base docs UI path (e.g. '/documentation')
disableInProductionboolean | 'public'The resolved disableInProduction value
docCountnumberTotal number of doc configs passed at registration
hasAuthbooleantrue if auth credentials were provided
environmentstring'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

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 }
Copyright © 2026