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 3.0.1 to 4.0.0

dist/favicon.png

28

dist/index.d.ts
import { Middleware } from 'koa';
export interface SwaggerOptions {
[key: string]: string | boolean | string[] | Record<string, unknown>;
dom_id: string;
url: string;
supportedSubmitMethods: string[];
docExpansion: string;
jsonEditor: boolean;
defaultModelRendering: string;
showRequestHeaders: boolean;
layout: string;
spec: Record<string, unknown>;
[key: string]: string | boolean | string[] | Record<string, unknown> | null | undefined;
dom_id?: string;
url?: string;
supportedSubmitMethods?: string[];
docExpansion?: string;
jsonEditor?: boolean;
defaultModelRendering?: string;
showRequestHeaders?: boolean;
layout?: string;
spec?: Record<string, unknown>;
validatorUrl?: string | null;
}

@@ -17,10 +18,11 @@ export interface KoaSwaggerUiOptions {

oauthOptions: boolean | any;
swaggerOptions: Partial<SwaggerOptions>;
swaggerOptions: SwaggerOptions;
swaggerVersion: string;
routePrefix: string | false;
specPrefix: string;
exposeSpec: boolean;
hideTopbar: boolean;
favicon16: string;
favicon32: string;
favicon: string;
}
declare function koaSwagger(config?: Partial<KoaSwaggerUiOptions>): Middleware;
export default koaSwagger;

@@ -20,6 +20,7 @@ "use strict";

routePrefix: '/docs',
specPrefix: '/docs/spec',
swaggerVersion: '',
exposeSpec: false,
hideTopbar: false,
favicon16: '/favicon-16x16.png',
favicon32: '/favicon-32x32.png',
favicon: '/favicon.png',
};

@@ -35,6 +36,4 @@ function koaSwagger(config = {}) {

// Setup icons
const extFavicon16 = config.favicon16;
const extFavicon32 = config.favicon32;
const favicon16Path = path_1.join(__dirname, defaultOptions.favicon16);
const favicon32Path = path_1.join(__dirname, defaultOptions.favicon32);
const extFavicon = config.favicon;
const faviconPath = path_1.join(__dirname, defaultOptions.favicon);
// Setup default options

@@ -50,2 +49,6 @@ const options = lodash_1.defaultsDeep(config, defaultOptions);

return function koaSwaggerUi(ctx, next) {
if (options.exposeSpec && ctx.path === options.specPrefix) {
ctx.body = options.swaggerOptions.spec;
return true;
}
if (options.routePrefix === false || ctx.path === options.routePrefix) {

@@ -56,12 +59,7 @@ ctx.type = 'text/html';

}
if (extFavicon16 === undefined && ctx.path === defaultOptions.favicon16) {
if (extFavicon === undefined && ctx.path === defaultOptions.favicon) {
ctx.type = 'image/png';
ctx.body = fs_1.createReadStream(favicon16Path);
ctx.body = fs_1.createReadStream(faviconPath);
return true;
}
if (extFavicon32 === undefined && ctx.path === defaultOptions.favicon32) {
ctx.type = 'image/png';
ctx.body = fs_1.createReadStream(favicon32Path);
return true;
}
return next();

@@ -68,0 +66,0 @@ };

{
"name": "koa2-swagger-ui",
"version": "3.0.1",
"version": "4.0.0",
"description": "Swagger UI middleware for koa",

@@ -15,8 +15,7 @@ "main": "./dist/index.js",

"prepare": "npm run build",
"build": "del dist && tsc -p tsconfig.build.json",
"postbuild": "cp lib/index.hbs dist && cp lib/favicon-32x32.png dist && cp lib/favicon-16x16.png dist",
"build": "del-cli dist && tsc -p tsconfig.build.json",
"postbuild": "cp lib/index.hbs dist && cp lib/favicon.png dist",
"test": "jest",
"test:watch": "jest --watch",
"test:ci": "jest --ci --coverage --no-cache",
"semantic-release": "semantic-release"
"test:ci": "jest --ci --coverage --no-cache"
},

@@ -30,26 +29,20 @@ "dependencies": {

"peerDependencies": {
"koa": ">=2.12.0"
"koa": ">=2.13.0"
},
"devDependencies": {
"@types/jest": "25.2.3",
"@ctrl/eslint-config": "1.0.2",
"@jest/globals": "26.1.0",
"@types/koa-router": "7.4.1",
"@types/lodash": "4.14.154",
"@types/node": "14.0.9",
"@types/supertest": "2.0.9",
"@typescript-eslint/eslint-plugin": "3.1.0",
"@typescript-eslint/parser": "3.1.0",
"@types/lodash": "4.14.157",
"@types/node": "14.0.14",
"@types/supertest": "2.0.10",
"del-cli": "3.0.1",
"eslint": "7.1.0",
"eslint-config-xo-space": "0.24.0",
"eslint-config-xo-typescript": "0.29.0",
"eslint-plugin-import": "2.20.2",
"jest": "26.0.1",
"jest": "26.1.0",
"koa": "2.11.0",
"koa-router": "9.0.1",
"semantic-release": "17.0.8",
"koa-router": "9.1.0",
"supertest": "4.0.2",
"swagger-ui-dist": "3.25.5",
"ts-jest": "26.1.0",
"swagger-ui-dist": "3.28.0",
"ts-jest": "26.1.1",
"ts-node": "8.10.2",
"typescript": "3.9.3"
"typescript": "3.9.6"
},

@@ -56,0 +49,0 @@ "release": {

@@ -40,7 +40,9 @@ # koa2-swagger-ui [![NPM version][npm-image]][npm-url] [![CircleCI](https://circleci.com/gh/scttcper/koa2-swagger-ui.svg?style=svg)](https://circleci.com/gh/scttcper/koa2-swagger-ui)

swaggerVersion: 'x.x.x' // read from package.json,
validatorUrl: null, // disable swagger-ui validator
},
routePrefix: '/docs', // route where the view is returned
specPrefix: '/docs/spec', // route where the spec is returned
exposeSpec: false, // expose spec file
hideTopbar: false, // hide swagger top bar
favicon16: '/favicon-16x16.png', // default icon 16x16, set for self icon
favicon32: '/favicon-32x32.png', // default icon 32x32, set for self icon
favicon: '/favicon.png', // default favicon
```

@@ -47,0 +49,0 @@

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