Swagger Injector
Adaptation of swagger ui to render the swagger view of a server's swagger documentation for a specified route.
If you're unfamiliar with swagger, I highly recommend checking it out.
Key
Usage
Koa
Build for ^2.x
- Assume ./swagger.json is a valid json file
- Working example
- Run
$ npm install && node examples/koa
- Request
localhost:3000/swagger
- Run
let Koa = ;let swagger = ; let app = ; app; app;
Express
- Assume ./swagger.json is a valid json file
- NOTE: authentication requires
cookie-parser
- Working example
- Run
$ npm install && node examples/express
- Request
localhost:3000/swagger
- Run
let express = ;let cookieParser = ;let swagger = ; let app = ; app; // REQUIREDapp; app;
Configuration
The following configuration example is a copy of the default configuration
path: './swagger.json' // Path to swagger file swagger: false // swagger json. If not set, it is read from the `path` file prefix: '' // Prefix applied to all routes assets: '/_swagger_' // Prefix for all assets, appended to prefix route: '/swagger' // Router to serve documentation css: false // Path to the css OR css string unauthorized: false // Unauth handler dist: '/dist' // Path to dist directory authentication: sources: 'query' 'body' // Accepted sources of auth key: false // Key for the auth value: false // Value for the auth
Author
License
MIT