Class: builderbase = new BuilderBase()

constructor(initialSpec: T) : BuilderBase

Parameters
Name Type Default Value Flags Description
initialSpec T

build() : T

Build the spec object.

withExtension(key: string, value: any) : this

Add a custom (extension) property to the spec object.

Parameters
Name Type Default Value Flags Description
key string

The property name starting with "x-".

value any

The property value.

Class: openapispecbuilder = new OpenApiSpecBuilder()

A builder for creating OpenApiSpec documents.

constructor() : OpenApiSpecBuilder

withOperation(verb: string, path: string, spec: OperationObject | OperationSpecBuilder) : this

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

Parameters
Name Type Default Value Flags Description
verb string

The HTTP verb.

path string

The path relative to basePath.

spec OperationObject | OperationSpecBuilder

Additional specification of the operation.

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

Define a new operation that returns a string response.

Parameters
Name Type Default Value Flags Description
verb string

The HTTP verb.

path string

The path relative to basePath.

operationName undefined | string optional

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

Class: operationspecbuilder = new OperationSpecBuilder()

A builder for creating OperationObject specifications.

constructor() : OperationSpecBuilder

withOperationName(name: string) : this

Define the operation name (controller method name).

Parameters
Name Type Default Value Flags 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.

Parameters
Name Type Default Value Flags Description
parameterSpec ParameterObject

withRequestBody(requestBodySpec: RequestBodyObject) : this

Parameters
Name Type Default Value Flags Description
requestBodySpec RequestBodyObject

A builder for creating OperationObject specifications.

withResponse(status: number | , responseSpec: ResponseObject) : this

Describe a response for a given HTTP status code.

Parameters
Name Type Default Value Flags Description
status number |

HTTP status code or string "default"

responseSpec ResponseObject

Specification of the response

withStringResponse(status: number | ) : this

Parameters
Name Type Default Value Flags Description
status number | 200

A builder for creating OperationObject specifications.

withTags(tags: string | string[]) : this

Describe tags associated with the operation

Parameters
Name Type Default Value Flags Description
tags string | string[]

Function: anOpenApiSpec

anOpenApiSpec() : OpenApiSpecBuilder

Create a new instance of OpenApiSpecBuilder.

Function: anOperationSpec

anOperationSpec() : OperationSpecBuilder

Create a new instance of OperationSpecBuilder.