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 - npm Package Compare versions

Comparing version 1.0.3 to 2.0.0

lib/index.hbs

3

examples/example.js
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

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