Skip to content

SudoSOS Back-end API / internal/swagger / Swagger

Class: Swagger ​

Constructors ​

Constructor ​

ts
new Swagger(): Swagger;

Returns ​

Swagger

Methods ​

generateSpecification() ​

ts
static generateSpecification(app, filesPattern): Promise<SwaggerSpecification>;

Generate Swagger specification on-demand and serve it.

Parameters ​

ParameterTypeDescription
appApplicationThe express application to mount on.
filesPatternstring[]Glob pattern to find your jsdoc files

Returns ​

Promise<SwaggerSpecification>

The Swagger specification with model validator.


importSpecification() ​

ts
static importSpecification(file?): Promise<SwaggerSpecification>;

Imports a pre-generated Swagger specification file.

Parameters ​

ParameterTypeDefault valueDescription
filestring'out/swagger.json'The path to the Swagger JSON file.

Returns ​

Promise<SwaggerSpecification>


initialize() ​

ts
static initialize(app): Promise<SwaggerSpecification>;

Initializes the Swagger specification for the current environment and serve it. Depending on the NODE_ENV, it will be generated on-demand or import a pre-generated specification.

Parameters ​

ParameterTypeDescription
appApplicationThe express application which will serve the specification.

Returns ​

Promise<SwaggerSpecification>