JSPM

  • Created
  • Published
  • Downloads 40644
  • Score
    100M100P100Q162571F
  • License MIT

Utility to inject swagger the doc GUI into a node API

Package Exports

  • koa2-swagger-ui

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (koa2-swagger-ui) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

koa2-swagger-ui

Host swagger ui at a given directory from your koa v2 app.

Inspired by:

install

npm install koa2-swagger-ui --save

config

for more swaggerOptions see swagger-ui defaults:

title: 'swagger', // page title
oauthOptions: {}, // passed to initOAuth
swaggerOptions: { // passed to SwaggerUi()
  supportedSubmitMethods: ['head', 'get', 'post', 'put', 'patch', 'delete'],
  apisSorter: 'alpha',
  operationsSorter: 'alpha',
  docExpansion: 'none',
},
routePrefix: '/docs', // route where the view is returned

example

const Koa = require('koa');
const koaSwagger = require(koa2-swagger-ui);

const app = new Koa();

// host at /swagger instead of default /docs
app.use(koaSwagger({
  routePrefix: '/swagger',
  url: 'http://petstore.swagger.io/v2/swagger.json' // example path to json
}));

app.listen(3000);