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',
oauthOptions: {},
swaggerOptions: {
dom_id: 'swagger-ui-container',
url: 'http://petstore.swagger.io/v2/swagger.json',
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
docExpansion: 'none',
jsonEditor: false,
defaultModelRendering: 'schema',
showRequestHeaders: false,
swaggerVersion: 'x.x.x'
},
routePrefix: '/docs',
hideTopbar: false,
favicon16: '/favicon-16x16.png',
favicon32: '/favicon-32x32.png',
example
const Koa = require('koa');
const koaSwagger = require('koa2-swagger-ui');
const app = new Koa();
app.use(
koaSwagger({
routePrefix: '/swagger',
swaggerOptions: {
url: 'http://petstore.swagger.io/v2/swagger.json',
},
}),
);
app.listen(3000);