OpenAPI doc generator.

[[include:openapi.md]]

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[]

  • Parameters

    • name: string
    • callback: unknown

    Returns OpenAPI

  • [[include:openapi.addDefaultSecurity.1.md]]

    Parameters

    • security: BaseAuthUtil | BaseContextAuthUtil | BaseOpenAPIAuthUtil

    Returns OpenAPI

  • Example:

    openapi.addDefaultSecurity({
    basicAuth: []
    });

    Parameters

    • security: string | SecurityRequirementObject

    Returns OpenAPI

  • Example:

    openapi.addDefaultSecurity({
    basicAuth: []
    });

    Parameters

    • security: SecurityRequirementObject

    Returns OpenAPI

  • Example:

    openapi.addDefaultSecurity('basicAuth');
    

    Parameters

    • security: string

    Returns OpenAPI

  • Parameters

    • name: string
    • example: ExampleObject | ReferenceObject

    Returns OpenAPI

  • Parameters

    • name: string
    • header: ReferenceObject | HeaderObject

    Returns OpenAPI

  • Parameters

    • name: string
    • link: ReferenceObject | LinkObject

    Returns OpenAPI

  • Parameters

    • name: string
    • param: ParameterObject

    Returns OpenAPI

  • Parameters

    • name: string
    • requestBody: ReferenceObject | RequestBodyObject

    Returns OpenAPI

  • Example:

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

    Parameters

    • name: string
    • response: ReferenceObject | ResponseObject

    Returns OpenAPI

  • [[include:openapi.addResponse.md]]

    Parameters

    • response: BaseResponseUtil | BaseOpenAPIResponseUtil

    Returns OpenAPI

  • Parameters

    • name: string
    • schema: ReferenceObject | SchemaObject

    Returns OpenAPI

  • [[include:openapi.addSecuritySchemes.1.md]]

    Parameters

    • name: string
    • schema: ReferenceObject | SecuritySchemeObject

    Returns OpenAPI

  • [[include:openapi.addSecuritySchemes.2.md]]

    Parameters

    • schema: BaseAuthUtil | BaseOpenAPIAuthUtil

    Returns OpenAPI

  • Parameters

    • server: ServerObject

    Returns OpenAPI

  • Parameters

    • url: string

    Returns OpenAPI

  • Parameters

    • tag: TagObject

    Returns OpenAPI

  • Parameters

    • tags: TagObject

    Returns OpenAPI

  • Parameters

    • tags: TagObject[]

    Returns OpenAPI

  • Returns Record<string, unknown>

    removed callbacks

  • remove unused entities (possibly auto-generated) from components:

    • headers
    • responses
    • requestBodies
    • parameters
    • schemas

    Returns ComponentsObject

  • Returns Record<string, ExampleObject | ReferenceObject>

    removed examples

  • Returns Record<string, ReferenceObject | HeaderObject>

    removed headers

  • Returns Record<string, ReferenceObject | LinkObject>

    removed links

  • Returns Record<string, ReferenceObject | ParameterObject>

    removed parameters

  • Returns Record<string, ReferenceObject | RequestBodyObject>

    removed requestBodies

  • Returns Record<string, ReferenceObject | ResponseObject>

    removed responses

  • Returns Record<string, ReferenceObject | SchemaObject>

    removed schemas

  • Returns Record<string, ReferenceObject | SecuritySchemeObject>

    removed securitySchemes

  • Returns undefined | Record<string, unknown>

  • Returns ComponentsObject

  • Returns string[]

  • Returns undefined | ContactObject

  • Returns SecurityRequirementObject[]

  • Returns undefined | string

  • Returns undefined | Record<string, ExampleObject | ReferenceObject>

  • Returns undefined | ExternalDocObject

  • Returns undefined | Record<string, ReferenceObject | HeaderObject>

  • Returns InfoObject

  • Returns undefined | LicenseObject

  • Returns undefined | Record<string, ReferenceObject | LinkObject>

  • Returns undefined | Record<string, ReferenceObject | ParameterObject>

  • Returns undefined | Record<string, ReferenceObject | RequestBodyObject>

  • Returns undefined | Record<string, ReferenceObject | ResponseObject>

  • Returns undefined | string

  • Returns undefined | Record<string, ReferenceObject | SchemaObject>

  • Returns undefined | Record<string, ReferenceObject | SecuritySchemeObject>

  • Returns ServerObject[]

  • Returns TagObject[]

  • Returns undefined | string

  • Returns string

  • Returns string

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • path: string
    • Optionalmethod: string

    Returns ProcessedRoute[]

  • remove all routes

    Returns ProcessedRoute[]

    The removed routes

  • Parameters

    • name: string

    Returns unknown

  • Parameters

    • name: string

    Returns undefined | ExampleObject | ReferenceObject

  • Parameters

    • name: string

    Returns undefined | ReferenceObject | HeaderObject

  • Parameters

    • name: string

    Returns undefined | ReferenceObject | LinkObject

  • Parameters

    • name: string

    Returns undefined | ReferenceObject | ParameterObject

  • Parameters

    • name: string

    Returns undefined | ReferenceObject | RequestBodyObject

  • Parameters

    • name: string

    Returns undefined | ReferenceObject | ResponseObject

  • Parameters

    • name: string

    Returns undefined | ReferenceObject | SchemaObject

  • Parameters

    • name: string

    Returns undefined | ReferenceObject | SecuritySchemeObject

  • Parameters

    • tagName: string

    Returns undefined | TagObject

  • Parameters

    • callbacks: Record<string, unknown>

    Returns OpenAPI

  • Parameters

    • components: ComponentsObject

    Returns OpenAPI

  • Parameters

    • consumes: string[]

    Returns OpenAPI

  • Parameters

    • contact: ContactObject

    Returns OpenAPI

  • [[include:openapi.setDefaultSecurity.1.md]]

    Parameters

    • security: BaseAuthUtil | BaseContextAuthUtil | BaseOpenAPIAuthUtil

    Returns OpenAPI

  • Parameters

    • securityObjects: SecurityRequirementObject[]

    Returns OpenAPI

  • Example:

    openapi.setDefaultSecurity({
    basicAuth: []
    });

    Parameters

    • securityObject: SecurityRequirementObject

    Returns OpenAPI

  • Parameters

    • security: string[]

    Returns OpenAPI

  • Example:

    openapi.setDefaultSecurity('basicAuth');
    

    Parameters

    • security: string

    Returns OpenAPI

  • Parameters

    • description: string

    Returns OpenAPI

  • Parameters

    • examples: Record<string, ExampleObject | ReferenceObject>

    Returns OpenAPI

  • Parameters

    • externalDoc: ExternalDocObject

    Returns OpenAPI

  • Parameters

    • url: string

    Returns OpenAPI

  • Parameters

    • headers: Record<string, ReferenceObject | HeaderObject>

    Returns OpenAPI

  • OpenAPI.setServers({ url })

    Parameters

    • url: string

    Returns OpenAPI

  • Parameters

    • info: InfoObject

    Returns OpenAPI

  • Parameters

    • prop: string
    • value: unknown

    Returns OpenAPI

  • Parameters

    • license: string

    Returns OpenAPI

  • Parameters

    • license: LicenseObject

    Returns OpenAPI

  • Parameters

    • links: Record<string, ReferenceObject | LinkObject>

    Returns OpenAPI

  • Parameters

    • parameters: Record<string, ReferenceObject | ParameterObject>

    Returns OpenAPI

  • Parameters

    • requestBodies: Record<string, ReferenceObject | RequestBodyObject>

    Returns OpenAPI

  • Parameters

    • responses: Record<string, ReferenceObject | ResponseObject>

    Returns OpenAPI

  • [[include:openapi.setResponses.md]]

    Parameters

    • responses: BaseResponseUtil | BaseOpenAPIResponseUtil

    Returns OpenAPI

  • Parameters

    • v: string

    Returns OpenAPI

  • Parameters

    • schemas: Record<string, ReferenceObject | SchemaObject>

    Returns OpenAPI

  • [[include:openapi.setSecuritySchemes.1.md]]

    Parameters

    • schemes: Record<string, ReferenceObject | SecuritySchemeObject>

    Returns OpenAPI

  • [[include:openapi.setSecuritySchemes.2.md]]

    Parameters

    • schemes: BaseAuthUtil | BaseOpenAPIAuthUtil

    Returns OpenAPI

  • Parameters

    • servers: ServerObject[]

    Returns OpenAPI

  • Parameters

    • server: ServerObject

    Returns OpenAPI

  • Parameters

    • tags: TagObject[]

    Returns OpenAPI

  • Parameters

    • termsOfService: string

    Returns OpenAPI

  • Parameters

    • title: string

    Returns OpenAPI

  • Parameters

    • version: string

    Returns OpenAPI