Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa2-swagger-ui

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa2-swagger-ui

Swagger UI middleware for koa

  • 2.5.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
37K
decreased by-15.73%
Maintainers
1
Weekly downloads
 
Created
Source

koa2-swagger-ui

NPM version build status coverage greenkeeper

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

Inspired by:

  • swagger-injector for serving on a specific route
  • hapi-swaggered-ui for serving files from node_modules using a handlebars driven index.html

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()
  dom_id: 'swagger-ui-container',
  url: 'http://petstore.swagger.io/v2/swagger.json', // link to swagger.json
  supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
  docExpansion: 'none',
  jsonEditor: false,
  defaultModelRendering: 'schema',
  showRequestHeaders: false,
  swaggerVersion: 'x.x.x' // read from package.json,
  
},
routePrefix: '/docs', // route where the view is returned
hideTopbar: false, // hide swagger top bar

example

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

const app = new Koa();


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

app.listen(3000);

Keywords

FAQs

Package last updated on 09 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc