koa-swagger-ui
Still missing:
- convert route outputs into swagger
- finish converting from joi-to-json-schema to joi-to-swagger (there's no npm link, but there is a github link)
- make tests to demonstrate
- find out why swagger-cli throws validate errors on anything I create.
A node module for generating Swagger 2.0 JSON definitions from existing koa-joi-router routes.
Example
const SwaggerAPI = SwaggerAPI;const Router = ;const Joi = RouterJoi;const router = ; router; router; router //if you use swagger-ui you will want path parameters so people can use the 'try it out' functionality, despite the fact that koa-joi-router doesn't support themrouter; swaggerAPI = ;swaggerAPI; let spec = swaggerAPI; console;
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
swaggerAPI.generateSpec(baseSpec)
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.