koa2-swagger-ui
Advanced tools
Comparing version 1.0.3 to 2.0.0
const Koa = require('koa'); | ||
const koaSwagger = require('../lib/'); | ||
const app = module.exports = new Koa(); | ||
const app = new Koa(); | ||
module.exports = app; | ||
@@ -6,0 +7,0 @@ app.use(koaSwagger()); |
@@ -5,16 +5,13 @@ const path = require('path'); | ||
const send = require('koa-send'); | ||
const swaggerUiPath = require('swagger-ui/index').dist; | ||
const Handlebars = require('handlebars'); | ||
const rootPath = path.join(__dirname, '../public'); | ||
const defaultOptions = { | ||
title: 'swagger', | ||
title: 'Swagger UI', | ||
oauthOptions: {}, | ||
swaggerOptions: { | ||
dom_id: 'swagger-ui-container', | ||
dom_id: '#swagger-ui', | ||
url: 'http://petstore.swagger.io/v2/swagger.json', | ||
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'], | ||
docExpansion: 'none', | ||
jsonEditor: false, | ||
defaultModelRendering: 'schema', | ||
showRequestHeaders: false, | ||
layout: 'StandaloneLayout', | ||
}, | ||
@@ -27,5 +24,5 @@ routePrefix: '/docs', | ||
Handlebars.registerHelper('json', context => JSON.stringify(context)); | ||
const index = Handlebars.compile(fs.readFileSync(path.join(__dirname, '../templates/index.hbs'), 'utf-8')); | ||
const index = Handlebars.compile(fs.readFileSync(path.join(__dirname, './index.hbs'), 'utf-8')); | ||
return (ctx, next) => { | ||
return function koaSwaggerUi(ctx, next) { | ||
if (ctx.path === options.routePrefix) { | ||
@@ -37,3 +34,3 @@ ctx.type = 'text/html'; | ||
const truePath = ctx.path.substring(options.routePrefix.length, ctx.path.length); | ||
return send(ctx, truePath, { root: swaggerUiPath }); | ||
return send(ctx, truePath, { root: rootPath }); | ||
} | ||
@@ -40,0 +37,0 @@ return next(); |
{ | ||
"name": "koa2-swagger-ui", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "Swagger UI middleware for koa", | ||
@@ -14,13 +14,12 @@ "main": "lib/index.js", | ||
"koa-send": "^3.3.0", | ||
"lodash.defaultsdeep": "^4.6.0", | ||
"swagger-ui": "^2.2.10" | ||
"lodash.defaultsdeep": "^4.6.0" | ||
}, | ||
"peerDependencies": { | ||
"koa": "^2.1.0" | ||
"koa": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^3.17.1", | ||
"eslint": "^3.18.0", | ||
"eslint-config-airbnb-base": "^11.1.1", | ||
"eslint-plugin-import": "^2.2.0", | ||
"koa": "^2.1.0", | ||
"koa": "^2.2.0", | ||
"mocha": "^3.2.0", | ||
@@ -27,0 +26,0 @@ "mocha-eslint": "^3.0.1", |
@@ -18,5 +18,5 @@ const lint = require('mocha-eslint'); | ||
}); | ||
it('should return jquery', function(done) { | ||
it('should return swagger-ui-bundle', function(done) { | ||
request(app.listen()) | ||
.get('/docs/lib/jquery-1.8.0.min.js') | ||
.get('/docs/swagger-ui-bundle.js') | ||
.expect('Content-Type', /javascript/) | ||
@@ -31,3 +31,3 @@ .expect(200) | ||
request(app.listen()) | ||
.get('/docs/images/favicon-32x32.png') | ||
.get('/docs/favicon-32x32.png') | ||
.expect('Content-Type', /image\/png/) | ||
@@ -34,0 +34,0 @@ .expect(200) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4331603
4
70
36401
4
6
- Removedswagger-ui@^2.2.10
- Removedswagger-ui@2.2.10(transitive)