Documentation
    Preparing search index...

    A router class for serving OpenAPI documentation via Express. Handles both UI presentation and raw spec file serving in JSON/YAML formats.

    const config = {
    filePathOrSpec: './openapi.yml',
    uiPath: '/api-docs',
    rawPath: '/spec'
    };
    const router = new OpenapiViewerRouter(config);
    router.setup();
    app.use('/', router.getRouter());

    The router must be setup using the setup() method before it can be used. The setup method can only be called once per instance.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Retrieves the configured Express router instance.

      Returns Router

      The configured Express router

      When called before running setup

    • Initializes the OpenAPI router with the specified configuration. Sets up routes for serving the OpenAPI specification in JSON and YAML formats, as well as configuring the Swagger UI endpoint.

      Returns void

      If setup is called more than once on the same instance

      The method performs the following:

      1. Loads the OpenAPI specification from file if path is provided, or uses the provided spec object
      2. Creates routes for serving the raw specification in different formats (.json, .yml, .yaml)
      3. Sets up the Swagger UI endpoint