class DocumentBuilder {
setTitle(title: string): this
setDescription(description: string): this
setVersion(version: string): this
setTermsOfService(termsOfService: string): this
setContact(name: string, url: string, email: string): this
setLicense(name: string, url: string): this
setOpenAPIVersion(version: string): this
addServer(url: string, description?: string, variables?: Record<string, ServerVariableObject>): this
setExternalDoc(description: string, url: string): this
setBasePath(path: string)
addTag(name: string, description: string = '', externalDocs?: ExternalDocumentationObject): this
addExtension(extensionKey: string, extensionProperties: any): this
addSecurity(name: string, options: SecuritySchemeObject): this
addGlobalParameters(...parameters: Omit<ParameterObject, "example" | "examples">[]): this
addSecurityRequirements(name: string | SecurityRequirementObject, requirements: string[] = []): this
addBearerAuth(options: SecuritySchemeObject = {...}, name: string = 'bearer'): this
addOAuth2(options: SecuritySchemeObject = {...}, name: string = 'oauth2'): this
addApiKey(options: SecuritySchemeObject = {...}, name: string = 'api_key'): this
addBasicAuth(options: SecuritySchemeObject = {...}, name: string = 'basic'): this
addCookieAuth(cookieName: string = 'connect.sid', options: SecuritySchemeObject = {...}, securityName: string = 'cookie'): this
build(): Omit<OpenAPIObject, 'paths'>
}
Methods
setTitle()
|
setTitle(title: string): this
Parameters
Option |
Type |
Description |
title
|
string |
|
Returns
this
|
setDescription()
|
setDescription(description: string): this
Parameters
Option |
Type |
Description |
description
|
string |
|
Returns
this
|
setVersion()
|
setVersion(version: string): this
Parameters
Option |
Type |
Description |
version
|
string |
|
Returns
this
|
setTermsOfService()
|
setTermsOfService(termsOfService: string): this
Parameters
Option |
Type |
Description |
termsOfService
|
string |
|
Returns
this
|
|
setContact(name: string, url: string, email: string): this
Parameters
Option |
Type |
Description |
name
|
string |
|
url
|
string |
|
email
|
string |
|
Returns
this
|
setLicense()
|
setLicense(name: string, url: string): this
Parameters
Option |
Type |
Description |
name
|
string |
|
url
|
string |
|
Returns
this
|
setOpenAPIVersion()
|
setOpenAPIVersion(version: string): this
Parameters
Option |
Type |
Description |
version
|
string |
|
Returns
this
|
addServer()
|
addServer(url: string, description?: string, variables?: Record<string, ServerVariableObject>): this
Parameters
Option |
Type |
Description |
url
|
string |
|
description
|
string |
Optional. Default is undefined .
|
variables
|
Record |
Optional. Default is undefined .
|
Returns
this
|
setExternalDoc()
|
setExternalDoc(description: string, url: string): this
Parameters
Option |
Type |
Description |
description
|
string |
|
url
|
string |
|
Returns
this
|
setBasePath()
|
setBasePath(path: string)
Parameters
Option |
Type |
Description |
path
|
string |
|
|
addTag()
|
addTag(name: string, description: string = '', externalDocs?: ExternalDocumentationObject): this
Parameters
Option |
Type |
Description |
name
|
string |
|
description
|
string |
Optional. Default is '' .
|
externalDocs
|
ExternalDocumentationObject |
Optional. Default is undefined .
|
Returns
this
|
addExtension()
|
addExtension(extensionKey: string, extensionProperties: any): this
Parameters
Option |
Type |
Description |
extensionKey
|
string |
|
extensionProperties
|
any |
|
Returns
this
|
addSecurity()
|
addSecurity(name: string, options: SecuritySchemeObject): this
Parameters
Option |
Type |
Description |
name
|
string |
|
options
|
SecuritySchemeObject |
|
Returns
this
|
addGlobalParameters()
|
addGlobalParameters(...parameters: Omit<ParameterObject, "example" | "examples">[]): this
Parameters
Option |
Type |
Description |
parameters
|
Omit[] |
|
Returns
this
|
addSecurityRequirements()
|
addSecurityRequirements(name: string | SecurityRequirementObject, requirements: string[] = []): this
Parameters
Option |
Type |
Description |
name
|
string | SecurityRequirementObject |
|
requirements
|
string[] |
Optional. Default is [] .
|
Returns
this
|
addBearerAuth()
|
addBearerAuth(options: SecuritySchemeObject = {
type: 'http'
}, name: string = 'bearer'): this
Parameters
Option |
Type |
Description |
options
|
SecuritySchemeObject |
Optional. Default is `{
type: 'http'
}`.
|
name
|
string |
Optional. Default is 'bearer' .
|
Returns
this
|
addOAuth2()
|
addOAuth2(options: SecuritySchemeObject = {
type: 'oauth2'
}, name: string = 'oauth2'): this
Parameters
Option |
Type |
Description |
options
|
SecuritySchemeObject |
Optional. Default is `{
type: 'oauth2'
}`.
|
name
|
string |
Optional. Default is 'oauth2' .
|
Returns
this
|
addApiKey()
|
addApiKey(options: SecuritySchemeObject = {
type: 'apiKey'
}, name: string = 'api_key'): this
Parameters
Option |
Type |
Description |
options
|
SecuritySchemeObject |
Optional. Default is `{
type: 'apiKey'
}`.
|
name
|
string |
Optional. Default is 'api_key' .
|
Returns
this
|
addBasicAuth()
|
addBasicAuth(options: SecuritySchemeObject = {
type: 'http'
}, name: string = 'basic'): this
Parameters
Option |
Type |
Description |
options
|
SecuritySchemeObject |
Optional. Default is `{
type: 'http'
}`.
|
name
|
string |
Optional. Default is 'basic' .
|
Returns
this
|
addCookieAuth()
|
addCookieAuth(cookieName: string = 'connect.sid', options: SecuritySchemeObject = {
type: 'apiKey'
}, securityName: string = 'cookie'): this
Parameters
Option |
Type |
Description |
cookieName
|
string |
Optional. Default is 'connect.sid' .
|
options
|
SecuritySchemeObject |
Optional. Default is `{
type: 'apiKey'
}`.
|
securityName
|
string |
Optional. Default is 'cookie' .
|
Returns
this
|
build()
|
build(): Omit<OpenAPIObject, 'paths'>
Parameters
There are no parameters.
Returns
Omit<OpenAPIObject, 'paths'>
|