SwaggerModule

  
class SwaggerModule {
  static createDocument(app: INestApplication, config: Omit<OpenAPIObject, "paths">, options: SwaggerDocumentOptions = {}): OpenAPIObject
  static loadPluginMetadata(metadataFn: () => Promise<Record<string, any>>)
  protected static serveStatic(finalPath: string, app: INestApplication, customStaticPath?: string)
  protected static serveDocuments(finalPath: string, urlLastSubdirectory: string, httpAdapter: HttpServer, documentOrFactory: OpenAPIObject | (() => OpenAPIObject), options: { ui: boolean; raw: boolean | ("json" | "yaml")[]; jsonDocumentUrl: string; yamlDocumentUrl: string; swaggerOptions: SwaggerCustomOptions; })
  protected static serveSwaggerUi(finalPath: string, urlLastSubdirectory: string, httpAdapter: HttpServer, getBuiltDocument: () => OpenAPIObject, swaggerOptions: SwaggerCustomOptions)
  protected static serveDefinitions(httpAdapter: HttpServer, getBuiltDocument: () => OpenAPIObject, options: { jsonDocumentUrl: string; yamlDocumentUrl: string; swaggerOptions: SwaggerCustomOptions; }, serveOptions: { serveJson: boolean; serveYaml: boolean; })
  static setup(path: string, app: INestApplication, documentOrFactory: OpenAPIObject | (() => OpenAPIObject), options?: SwaggerCustomOptions)
}

Static methods

createDocument()


static createDocument(app: INestApplication, config: Omit<OpenAPIObject, "paths">, options: SwaggerDocumentOptions = {}): OpenAPIObject

Parameters

Option Type Description
app INestApplication
config Omit
options SwaggerDocumentOptions

Optional. Default is {}.

Returns

OpenAPIObject

loadPluginMetadata()


static loadPluginMetadata(metadataFn: () => Promise<Record<string, any>>)

Parameters

Option Type Description
metadataFn () => Promise>

serveStatic()


protected static serveStatic(finalPath: string, app: INestApplication, customStaticPath?: string)

Parameters

Option Type Description
finalPath string
app INestApplication
customStaticPath string

Optional. Default is undefined.

serveDocuments()


protected static serveDocuments(finalPath: string, urlLastSubdirectory: string, httpAdapter: HttpServer, documentOrFactory: OpenAPIObject | (() => OpenAPIObject), options: { ui: boolean; raw: boolean | ("json" | "yaml")[]; jsonDocumentUrl: string; yamlDocumentUrl: string; swaggerOptions: SwaggerCustomOptions; })

Parameters

Option Type Description
finalPath string
urlLastSubdirectory string
httpAdapter HttpServer
documentOrFactory OpenAPIObject | (() => OpenAPIObject)
options object

serveSwaggerUi()


protected static serveSwaggerUi(finalPath: string, urlLastSubdirectory: string, httpAdapter: HttpServer, getBuiltDocument: () => OpenAPIObject, swaggerOptions: SwaggerCustomOptions)

Parameters

Option Type Description
finalPath string
urlLastSubdirectory string
httpAdapter HttpServer
getBuiltDocument () => OpenAPIObject
swaggerOptions SwaggerCustomOptions

serveDefinitions()


protected static serveDefinitions(httpAdapter: HttpServer, getBuiltDocument: () => OpenAPIObject, options: { jsonDocumentUrl: string; yamlDocumentUrl: string; swaggerOptions: SwaggerCustomOptions; }, serveOptions: { serveJson: boolean; serveYaml: boolean; })

Parameters

Option Type Description
httpAdapter HttpServer
getBuiltDocument () => OpenAPIObject
options object
serveOptions object

setup()


static setup(path: string, app: INestApplication, documentOrFactory: OpenAPIObject | (() => OpenAPIObject), options?: SwaggerCustomOptions)

Parameters

Option Type Description
path string
app INestApplication
documentOrFactory OpenAPIObject | (() => OpenAPIObject)
options SwaggerCustomOptions

Optional. Default is undefined.