Skip to content

Latest commit

 

History

History
58 lines (41 loc) · 1.71 KB

README.md

File metadata and controls

58 lines (41 loc) · 1.71 KB

koa-joi-router docs generator

NPM version npm download

This project is based on chuyik/koa-joi-router-docs.

A node module for generating Swagger 2.0 JSON definitions from existing koa-joi-router routes.

Installation

Install using npm:

npm install @rudi23/koa-joi-router-docs

NodeJS >= 12.0.0. is required.

Example

Visit example/ folder to see the full example.

API

new SwaggerAPI()

Creates a new SwaggerAPI instance.

swaggerAPI.addJoiRouter(router, options)

Add a joi-router instance to the API. The router should already have all its routes set up before calling this method (which pulls the route definitions from the router's .routes property).

Options:

  • prefix: prefix to add to Swagger path (use prefix from JoiRouter if not set)

swaggerAPI.generateSpec(baseSpec, options)

Create a Swagger specification for this API. A base specification should be provided with an info object (containing at least the title and version strings) and any other global descriptions.

Options:

  • defaultResponses: xustom default responses
    {
      200: {
        description: 'Success'
      }
    }