OpenAPI doc generator.

Note

For now it is not possible to only send files outside of object property (multipart). Well, at least not tried yet but it definitely doesn't work with alternatives.

Implements

Constructors

Methods

  • Example:

    openapi.addResponse('200', {
    "description": "A simple string response",
    "content": {
    "text/plain": {
    "schema": {
    "type": "string",
    "example": "whoa!"
    }
    }
    }
    });

    Parameters

    Returns OpenAPI

  • Example:

    import {
    ResponseUtil,
    GroupResponseUtil
    } from '@novice1/api-doc-generator';

    const generalError = new ResponseUtil('GeneralError');
    generalError
    .setDescription('General Error')
    .addMediaType('application/json', {
    schema: {
    $ref: '#/components/schemas/GeneralError'
    }
    });

    const illegalInput = new ResponseUtil('IllegalInput');
    illegalInput
    .setDescription('Illegal input for operation.');

    const responses = new GroupResponseUtil([
    generalError,
    illegalInput
    ]);

    openapi.addResponse(responses);
    // or
    openapi
    .addResponse(generalError)
    .addResponse(illegalInput);

    Returns OpenAPI

  • Returns Record<string, unknown>

    removed callbacks

  • Returns undefined | Record<string, unknown>

  • Parameters

    Returns OpenAPI

  • Example:

    import {
    ResponseUtil,
    GroupResponseUtil
    } from '@novice1/api-doc-generator';

    const generalError = new ResponseUtil('GeneralError');
    generalError
    .setDescription('General Error')
    .addMediaType('application/json', {
    schema: {
    $ref: '#/components/schemas/GeneralError'
    }
    });

    const responses = new GroupResponseUtil([
    generalError,
    // ... other responses
    ]);

    openapi.setResponses(generalError);
    // or
    openapi.setResponses(responses);

    Returns OpenAPI