Socket
Socket
Sign inDemoInstall

swagger-ui-express

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-ui-express - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

7

index.js

@@ -10,3 +10,3 @@ 'use strict'

var setup = function(swaggerDoc, explorer, options, customCss, customfavIcon) {
var setup = function(swaggerDoc, explorer, options, customCss, customfavIcon, swaggerUrl) {
options = options || {};

@@ -22,3 +22,3 @@ var explorerString = explorer ? '' : '.swagger-ui .topbar .download-url-wrapper { display: none }';

}
var htmlWithSwaggerReplaced = html.toString().replace('<% swaggerDoc %>', JSON.stringify(swaggerDoc));
var htmlWithSwaggerReplaced = html.toString().replace('<% swaggerDoc %>', swaggerDoc ? JSON.stringify(swaggerDoc) : 'undefined');
var favIconString = customfavIcon ? '<link rel="icon" href="' + customfavIcon + '" />' : favIconHtml;

@@ -28,4 +28,5 @@ var indexHTML = htmlWithSwaggerReplaced.replace('<% customOptions %>', stringify(options))

var htmlWithFavIcon = htmlWithCustomCss.replace('<% favIconString %>', favIconString);
var htmlWithSwaggerUrl = htmlWithFavIcon.replace('<% swaggerUrl %>', swaggerUrl ? '"' + swaggerUrl + '"' : 'undefined')
return function(req, res) { res.send(htmlWithFavIcon) };
return function(req, res) { res.send(htmlWithSwaggerUrl) };
};

@@ -32,0 +33,0 @@

{
"name": "swagger-ui-express",
"version": "2.0.3",
"version": "2.0.4",
"description": "Swagger UI Express",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -90,2 +90,17 @@ # Swagger UI Express

### Load swagger from url
To load your swagger from a url instead of injecting the document, pass `null` as the first parameter, and pass the relative or absolute URL as the sixth parameter.
```javascript
const express = require('express');
const app = express();
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');
app.static
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(null, null, null, null, null, 'http://petstore.swagger.io/v2/swagger.json'));
```
## Requirements

@@ -92,0 +107,0 @@

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