Setu-TS
    Preparing search index...

    Function OpenApiPlugin

    • Creates an OpenAPI plugin that auto-generates OpenAPI 3.1 documentation from registered routes and serves it (with optional Swagger UI).

      The plugin:

      • Registers an IOpenApiService under CAPABILITIES.OPENAPI
      • Drains CAPABILITIES.OPENAPI_SCHEMA contributions at registration
      • Serves the spec at specEndpoint (default /openapi.json)
      • Serves Swagger UI at endpoint (default /docs) when swagger !== false
      • Omits its own two endpoints from the document, plus anything named in OpenApiGeneratorOptions.exclude

      Declaring securitySchemes is what gives Swagger UI its Authorize button. Pair it with security to state that operations require authentication by default; an individual route opts out with schema: { security: [] }.

      Parameters

      Returns IPlugin

      An IPlugin instance

      If Swagger asset options are invalid

      At registration if self-hosting cannot load swagger-ui-dist

      At bootstrap if an included declared operation id is blank or duplicated

      app.register(OpenApiPlugin({
      title: 'My API',
      version: '1.0.0',
      endpoint: '/docs',
      specEndpoint: '/openapi.json',
      securitySchemes: {
      bearerAuth: { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
      },
      security: [{ bearerAuth: [] }],
      exclude: ['/health', '/live', '/ready', '/metrics'],
      }));

      0.1.0