swagger-ui-express
Advanced tools
Comparing version 4.3.0 to 4.4.0
21
index.js
@@ -9,2 +9,6 @@ 'use strict' | ||
function trimQuery(q) { | ||
return q && q.split('?')[0] | ||
} | ||
var htmlTplString = ` | ||
@@ -82,2 +86,3 @@ <!-- HTML for static distribution bundle build --> | ||
<% customJs %> | ||
<% customJsStr %> | ||
<% customCssUrl %> | ||
@@ -141,2 +146,3 @@ <style> | ||
var customJs | ||
var customJsStr | ||
var swaggerUrls | ||
@@ -148,2 +154,3 @@ var customCssUrl | ||
customJs = opts.customJs | ||
customJsStr = opts.customJsStr | ||
customfavIcon = opts.customfavIcon | ||
@@ -170,3 +177,4 @@ swaggerUrl = opts.swaggerUrl | ||
var htmlWithFavIcon = htmlWithCustomCss.replace('<% favIconString %>', favIconString) | ||
var htmlWithCustomJs = htmlWithFavIcon.replace('<% customJs %>', customJs ? `<script src="${customJs}"></script>` : '') | ||
var htmlWithCustomJsUrl = htmlWithFavIcon.replace('<% customJs %>', customJs ? `<script src="${customJs}"></script>` : '') | ||
var htmlWithCustomJs = htmlWithCustomJsUrl.replace('<% customJsStr %>', customJsStr ? `<script>${customJsStr}</script>` : '') | ||
var htmlWithCustomCssUrl = htmlWithCustomJs.replace('<% customCssUrl %>', customCssUrl ? `<link href="${customCssUrl}" rel="stylesheet">` : '') | ||
@@ -198,5 +206,5 @@ | ||
function swaggerInitFn(req, res, next) { | ||
if (req.url === '/package.json') { | ||
if (trimQuery(req.url) === '/package.json') { | ||
res.sendStatus(404) | ||
} else if (req.url === '/swagger-ui-init.js') { | ||
} else if (trimQuery(req.url) === '/swagger-ui-init.js') { | ||
res.set('Content-Type', 'application/javascript') | ||
@@ -212,5 +220,8 @@ res.send(swaggerInit) | ||
return function (req, res, next) { | ||
if (req.url === '/package.json') { | ||
if (trimQuery(req.url) === '/package.json') { | ||
res.sendStatus(404) | ||
} else if (req.url === '/swagger-ui-init.js') { | ||
} else if (trimQuery(req.url) === '/swagger-ui-init.js') { | ||
if (req.swaggerDoc) { | ||
swaggerInitFile = jsTplString.toString().replace('<% swaggerOptions %>', stringify(opts)) | ||
} | ||
res.set('Content-Type', 'application/javascript') | ||
@@ -217,0 +228,0 @@ res.send(swaggerInitFile) |
{ | ||
"name": "swagger-ui-express", | ||
"version": "4.3.0", | ||
"version": "4.4.0", | ||
"description": "Swagger UI Express", | ||
@@ -53,3 +53,3 @@ "main": "./index.js", | ||
"dependencies": { | ||
"swagger-ui-dist": ">=4.1.3" | ||
"swagger-ui-dist": ">=4.11.0" | ||
}, | ||
@@ -56,0 +56,0 @@ "peerDependencies": { |
@@ -226,2 +226,4 @@ # Swagger UI Express | ||
var options = {} | ||
app.use('/api-docs', function(req, res, next){ | ||
@@ -231,3 +233,3 @@ swaggerDocument.host = req.get('host'); | ||
next(); | ||
}, swaggerUi.serve, swaggerUi.setup()); | ||
}, swaggerUi.serveFiles(swaggerDocument, options), swaggerUi.setup()); | ||
``` | ||
@@ -234,0 +236,0 @@ |
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
20905
241
283
Updatedswagger-ui-dist@>=4.11.0