OpenAPI doc generator.

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

  • Parameters

    • routes: RouteMeta[]

    Returns ProcessedRoute[]

    The added/updated routes

    import routing from '@novice1/routing';
    import { OpenAPI } from '@novice1/api-doc-generator';

    const router = routing().post(...);
    const openapi = new OpenAPI();
    const routes = openapi.add(router.getMeta());
    const { path, method, schema } = routes[0];
  • Parameters

    • routes: RouteMeta

    Returns ProcessedRoute[]

    The added/updated routes

    import routing from '@novice1/routing';
    import { OpenAPI } from '@novice1/api-doc-generator';

    const router = routing().post(...);
    const openapi = new OpenAPI();
    const routes = openapi.add(router.getMeta());
    const { path, method, schema } = routes[0];
  • 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>