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: string;
}

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
environmentstringThe environment option passed at registration (default '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 },
  environment: process.env.NODE_ENV,
});

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