Class: openapispecbuilder = new OpenApiSpecBuilder()

A builder for creating OpenApiSpec documents.

constructor(basePath: string) : OpenApiSpecBuilder

Arguments
Name Type Description
basePath string

The base path on which the API is served.

build() : OpenApiSpec

Build the OpenApiSpec object.

withOperation(verb: string, path: string, spec: undefined) : this

Define a new OperationObject at the given path and verb (method).

Arguments
Name Type Description
verb string

The HTTP verb.

path string

The path relative to basePath.

spec

Additional specification of the operation.

withOperationReturningString(verb: string, path: string, operationName: string) : this

Define a new operation that returns a string response.

Arguments
Name Type Description
verb string

The HTTP verb.

path string

The path relative to basePath.

operationName string

The name of the controller method implementing this operation (x-operation-name field).

Class: operationspecbuilder = new OperationSpecBuilder()

A builder for creating OperationObject specifications.

build() : OperationObject

Build the OperationObject object.

withOperationName(name: string) : this

Define the operation name (controller method name).

Arguments
Name Type Description
name string

The name of the controller method implementing this operation.

withParameter(parameterSpec: ParameterObject) : this

Describe a parameter accepted by the operation. Note that parameters are positional in OpenAPI Spec, therefore the first call of withParameter defines the first parameter, the second call defines the second parameter, etc.

Arguments
Name Type Description
parameterSpec ParameterObject

withResponse(status: undefined, responseSpec: ResponseObject) : this

Describe a response for a given HTTP status code.

Arguments
Name Type Description
status

HTTP status code or string "default"

responseSpec ResponseObject

Specification of the response

withStringResponse(status: undefined) : this

Arguments
Name Type Description
status

A builder for creating OperationObject specifications.

anOpenApiSpec(basePath: string) : OpenApiSpecBuilder

Create a new instance of OpenApiSpecBuilder.

Arguments
Name Type Description
basePath string

The base path on which the API is served.

anOperationSpec() : OperationSpecBuilder

Create a new instance of OperationSpecBuilder.