swagger-ui-express
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -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
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
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
1865677
7205
115