SwaggerCustomOptions


interface SwaggerCustomOptions {
  useGlobalPrefix?: boolean
  swaggerUiEnabled?: boolean
  ui?: boolean
  raw?: boolean | Array<'json' | 'yaml'>
  swaggerUrl?: string
  jsonDocumentUrl?: string
  yamlDocumentUrl?: string
  patchDocumentOnRequest?: <TRequest = any, TResponse = any>(req: TRequest, res: TResponse, document: OpenAPIObject) => OpenAPIObject
  explorer?: boolean
  swaggerOptions?: SwaggerUiOptions
  customCss?: string
  customCssUrl?: string | string[]
  customJs?: string | string[]
  customJsStr?: string | string[]
  customfavIcon?: string
  customSiteTitle?: string
  customSwaggerUiPath?: string
  validatorUrl?: string
  url?: string
  urls?: Record<'url' | 'name', string>[]
}

Properties

Property Description
useGlobalPrefix?: boolean

If true, Swagger resources paths will be prefixed by the global prefix set through setGlobalPrefix(). Default: false.

swaggerUiEnabled?: boolean

If false, the Swagger UI will not be served. Only API definitions (JSON and YAML) will be accessible (on /{path}-json and /{path}-yaml). To fully disable both the Swagger UI and API definitions, use raw: false. Default: true.

ui?: boolean

If false, the Swagger UI will not be served. Only API definitions (JSON and YAML) will be accessible (on /{path}-json and /{path}-yaml). To fully disable both the Swagger UI and API definitions, use raw: false. Default: true.

raw?: boolean | Array<'json' | 'yaml'>

If true, raw definitions for all formats will be served. Alternatively, you can pass an array to specify the formats to be served, e.g., raw: ['json'] to serve only JSON definitions. If omitted or set to an empty array, no definitions (JSON or YAML) will be served. Use this option to control the availability of Swagger-related endpoints. Default: true.

swaggerUrl?: string

Url point the API definition to load in Swagger UI.

jsonDocumentUrl?: string

Path of the JSON API definition to serve. Default: {{path}}-json.

yamlDocumentUrl?: string

Path of the YAML API definition to serve. Default: {{path}}-json.

patchDocumentOnRequest?: <TRequest = any, TResponse = any>(req: TRequest, res: TResponse, document: OpenAPIObject) => OpenAPIObject

Hook allowing to alter the OpenAPI document before being served. It's called after the document is generated and before it is served as JSON & YAML.

explorer?: boolean

If true, the selector of OpenAPI definitions is displayed in the Swagger UI interface. Default: false.

swaggerOptions?: SwaggerUiOptions

Additional Swagger UI options

customCss?: string

Custom CSS styles to inject in Swagger UI page.

customCssUrl?: string | string[]

URL(s) of a custom CSS stylesheet to load in Swagger UI page.

customJs?: string | string[]

URL(s) of custom JavaScript files to load in Swagger UI page.

customJsStr?: string | string[]

Custom JavaScript scripts to load in Swagger UI page.

customfavIcon?: string

Custom favicon for Swagger UI page.

customSiteTitle?: string

Custom title for Swagger UI page.

customSwaggerUiPath?: string

File system path (ex: ./node_modules/swagger-ui-dist) containing static Swagger UI assets.

validatorUrl?: string
url?: string
urls?: Record<'url' | 'name', string>[]