Configuration

The UI has no build-time configuration: it resolves the spec to render entirely at runtime, via one rule with one override.

One rule, one override

SourceWhenExample
GET /api-jsonDefault: matches what SwaggerModule.setup() from @nestjs/swagger exposes alongside Swagger UIhttps://api.example.com/docs → fetches https://api.example.com/api-json
?spec=<url>Query param: takes precedence over the default when presenthttps://docs.example.com/?spec=https://api.example.com/api-json

CORS across different origins

If the UI is served on a different origin from the API, use the ?spec= override and make sure the API's CORS configuration allows that origin to GET the JSON document.

This same-origin question comes up again for request execution: see Try it out for how its proxy sidesteps CORS entirely, without touching the API's own configuration.

Multiple specs

Pass specs to DocfyUiModule.setup() to let users switch between several OpenAPI documents without leaving the UI, useful when one docfy-ui instance should cover multiple services:

main.ts
DocfyUiModule.setup('/docs', app, {
  specs: [
    { name: 'Users service', url: 'https://users.example.com/api-json' },
    { name: 'Orders service', url: 'https://orders.example.com/api-json' },
  ],
});

Each url is fetched client-side exactly like the default /api-json spec is (same-origin or not, subject to that origin's CORS policy). A dropdown appears in the sidebar only when two or more specs are configured. Omit specs entirely and docfy-ui behaves exactly as before, no switcher rendered.