Gathering detailed insights and metrics for @roboto_/koa2-swagger-ui
Gathering detailed insights and metrics for @roboto_/koa2-swagger-ui
Gathering detailed insights and metrics for @roboto_/koa2-swagger-ui
Gathering detailed insights and metrics for @roboto_/koa2-swagger-ui
npm install @roboto_/koa2-swagger-ui
Typescript
Module System
Node Version
NPM Version
62
Supply Chain
95.2
Quality
74.3
Maintenance
100
Vulnerability
98.6
License
TypeScript (57.03%)
Handlebars (42.97%)
Total Downloads
221
Last Day
1
Last Week
3
Last Month
14
Last Year
67
357 Commits
1 Watching
1 Branches
1 Contributors
Latest Version
0.0.1
Package Id
@roboto_/koa2-swagger-ui@0.0.1
Unpacked Size
22.36 kB
Size
7.98 kB
File Count
8
NPM Version
8.19.2
Node Version
18.12.1
Publised On
06 Oct 2023
Cumulative downloads
Total Downloads
Last day
-50%
1
Compared to previous day
Last week
-40%
3
Compared to previous week
Last month
250%
14
Compared to previous month
Last year
-56.5%
67
Compared to previous year
Host swagger ui at a given directory from your koa v2 app
Inspired by:
npm install koa2-swagger-ui --save
for more swaggerOptions see swagger-ui defaults:
1title: 'swagger', // page title 2oauthOptions: {}, // passed to initOAuth 3swaggerOptions: { // passed to SwaggerUi() 4 dom_id: 'swagger-ui-container', 5 url: 'http://petstore.swagger.io/v2/swagger.json', // link to swagger.json 6 supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'], 7 docExpansion: 'none', 8 jsonEditor: false, 9 defaultModelRendering: 'schema', 10 showRequestHeaders: false, 11 swaggerVersion: 'x.x.x' // read from package.json, 12 validatorUrl: null, // disable swagger-ui validator 13}, 14routePrefix: '/docs', // route where the view is returned 15specPrefix: '/docs/spec', // route where the spec is returned 16exposeSpec: false, // expose spec file 17hideTopbar: false, // hide swagger top bar 18favicon: '/favicon.png', // default favicon 19customCSS: `h1 { color: red }`, // Add Custom CSS on the html
1import Koa from 'koa'; 2import { koaSwagger } from 'koa2-swagger-ui'; 3 4const app = new Koa(); 5 6app.use( 7 koaSwagger({ 8 routePrefix: '/swagger', // host at /swagger instead of default /docs 9 swaggerOptions: { 10 url: 'http://petstore.swagger.io/v2/swagger.json', // example path to json 11 }, 12 }), 13); 14 15app.listen(3000);
depends on yamljs to turn your Yaml into a JS object
npm install --save yamljs
1const Koa = require('koa'); 2const Router = require('koa-router'); 3const yamljs = require('yamljs'); 4const koaSwagger = require('koa2-swagger-ui'); 5 6const router = new Router({ prefix: '/' }); 7 8const app = new Koa(); 9const router = new Router(); 10 11// .load loads file from root. 12const spec = yamljs.load('./openapi.yaml'); 13 14// example 1 using router.use() 15router.use(koaSwagger({ swaggerOptions: { spec } })); 16 17// example 2 using more explicit .get() 18router.get('/docs', koaSwagger({ routePrefix: false, swaggerOptions: { spec } })); 19 20app.use(router.routes()); 21app.listen(3000);
No vulnerabilities found.
No security vulnerabilities found.