From ec32130c14789c901d3e2d3e0d2a73a1c65e1be4 Mon Sep 17 00:00:00 2001 From: Stephen Scott Date: Fri, 13 May 2022 10:24:47 +0100 Subject: [PATCH] fix dynamic loading for serveFiles and added customJsStr --- README.md | 4 +++- index.js | 9 ++++++++- test/testapp/app.js | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3101364..85cb48f 100644 --- a/README.md +++ b/README.md @@ -223,11 +223,13 @@ const app = express(); const swaggerUi = require('swagger-ui-express'); const swaggerDocument = require('./swagger.json'); +var options = {} + app.use('/api-docs', function(req, res, next){ swaggerDocument.host = req.get('host'); req.swaggerDoc = swaggerDocument; next(); -}, swaggerUi.serve, swaggerUi.setup()); +}, swaggerUi.serveFiles(swaggerDocument, options), swaggerUi.setup()); ``` ### Two swagger documents diff --git a/index.js b/index.js index 9b74230..a8cd5ac 100644 --- a/index.js +++ b/index.js @@ -82,6 +82,7 @@ var htmlTplString = ` <% customJs %> +<% customJsStr %> <% customCssUrl %>