1.0.0 • Published 2 years ago

@rudi23/koa-joi-router-docs v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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'
      }
    }