Hierarchy

  • DocumentBuilder

Constructors

Properties

_document: Document<{}>
components: Map<string, Component>
instance?: DocumentBuilder

Accessors

Methods

  • A builder method to generate allOf schemas.

    Returns

    A valid allOf schema object, using $ref syntax to reference component schemas

    Parameters

    • names: string[]

      List of names of schemas in the components of this document

    Returns SchemaObject

  • A builder method to generate anyOf schemas.

    Returns

    A valid anyOf schema object, using $ref syntax to reference component schemas

    Parameters

    • names: string[]

      List of names of schemas in the components of this document

    Returns SchemaObject

  • Parameters

    • app: Express
    • requireOpenApiDocs: boolean
    • includeExcludedPaths: boolean

    Returns PathsObject<{}, {}>

  • A method for adding and retrieving callback components from the document

    Returns

    The callback or undefined if it doesn't exist on the document

    Parameters

    • name: string

      The name of the callback component

    • Optional params: ComponentParameter

      Options

    Returns undefined | ReferenceObject | CallbackObject

  • A builder method that can create an allOf, oneOf, anyOf schema objects.

    Returns

    A valid allOf, oneOf, anyOf schema object, using $ref syntax to reference component schemas

    Throws

    Error if a component name doesn't exist on the document

    Parameters

    • type: CompositeSchemaTypes

      One of 'anyOf', 'oneOf', 'allOf', selecting which will be created

    • names: string[]

      List of names of schemas in the components of this document

    Returns SchemaObject

  • A method for adding and retrieving example components from the document

    Returns

    The example or undefined if it doesn't exist on the document

    Parameters

    • name: string

      The name of the example component

    • Optional params: ComponentParameter

      Options

    Returns undefined | ReferenceObject | ExampleObject

  • Parses the express app and builds an OpenApiv3 Paths object

    Remarks

    Warning: This must be used after all other routes have been attached and processed onto the express app. Suggested to be placed right before app.listen().

    You may use this, build a document, then use this method with different flags and build again for multiple versions of the OpenApi v3 document.

    This allows you to remove routes you don't want documented on one doc, but include it on another.

    Parameters

    • app: Express

      The Express App object

    • requireOpenApiDocs: boolean = false

      Require extended OpenApi middleware documentation to exist to include the route in the final Paths Object

    • includeExcludedPaths: boolean = false

      Override the exclude flag that was attached by middleware and include those routes in the final Paths Object

    Returns void

  • A method for adding and retrieving header components from the document

    Returns

    The header or undefined if it doesn't exist on the document

    Parameters

    • name: string

      The name of the header component

    • Optional params: ComponentParameter

      Options

    Returns undefined | ReferenceObject | HeaderObject

  • A method for adding and retrieving link components from the document

    Returns

    The link or undefined if it doesn't exist on the document

    Parameters

    Returns undefined | ReferenceObject | LinkObject

  • Parameters

    • parameters: (ReferenceObject | ParameterObject)[]
    • path: RouteMetaData

    Returns (ReferenceObject | ParameterObject)[]

  • A builder method to generate oneOf schemas.

    Returns

    A valid oneOf schema object, using $ref syntax to reference component schemas

    Parameters

    • names: string[]

      List of names of schemas in the components of this document

    Returns SchemaObject

  • A method for adding and retrieving parameter components from the document

    Returns

    The parameter or undefined if it doesn't exist on the document

    Parameters

    • name: string

      The name of the parameter component

    • Optional params: ComponentParameter

      Options

    Returns undefined | ReferenceObject | ParameterObject

  • A method for adding and retrieving requestBody components from the document

    Returns

    The requestBody or undefined if it doesn't exist on the document

    Parameters

    • name: string

      The name of the requestBody component

    • Optional params: ComponentParameter

      Options

    Returns undefined | ReferenceObject | RequestBodyObject

  • A method for adding and retrieving response components from the document

    Returns

    The response or undefined if it doesn't exist on the document

    Parameters

    • name: string

      The name of the response component

    • Optional params: ComponentParameter

      Options

    Returns undefined | ReferenceObject | ResponseObject

  • A method for adding and retrieving schema components from the document

    Returns

    The schema or undefined if it doesn't exist on the document

    Parameters

    • name: string

      The name of the schema component

    • Optional params: ComponentParameter

      Options

    Returns undefined | ReferenceObject | SchemaObject

  • A method for adding and retrieving securityScheme components from the document

    Returns

    The securityScheme or undefined if it doesn't exist on the document

    Parameters

    • name: string

      The name of the securityScheme component

    • Optional params: ComponentParameter

      Options

    Returns undefined | ReferenceObject | SecuritySchemeObject

  • Deletes the singleton instance, allowing re-initialization if desired.

    Returns void

  • Initializes and returns an instance of a DocumentBuilder that is not attached to the static reference of DocumentBuilder. Allows you to create a second document builder object, export it and use however desired.

    Does NOT override the underlying singleton instance

    Returns

    The newly created document builder object

    Parameters

    • documentStub: Document<{}>

      The minimum required OpenApiv3 skeleton spec

    Returns DocumentBuilder

  • Initializes the singleton document. This allows you to import this class from any module and maintain an global document reference.

    Remarks

    Warning: Each call to this method will override previous instances, loosing the internal document. Recommended to only call this once per project.

    Returns

    The document builder object instance

    Parameters

    • documentStub: Document<{}>

      The minimum required OpenApiv3 skeleton spec

    Returns DocumentBuilder

Generated using TypeDoc