From 7f351f062e44435629c0a73da60e6b1f4e5c137b Mon Sep 17 00:00:00 2001 From: Martin Danielsson Date: Sat, 13 Jan 2018 15:23:44 +0100 Subject: [PATCH] Fixes regression bug Haufe-Lexware/wicked.haufe.io#99 With the implementation of the href referencing, the overwriting of host, basePath and schemes was lost. Dammit. --- routes/apis.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/routes/apis.js b/routes/apis.js index 2a613cf..d2ac6df 100644 --- a/routes/apis.js +++ b/routes/apis.js @@ -364,7 +364,7 @@ function injectTokenEndpoint(globalSettings, swaggerJson) { // } // } const _swaggerMap = {}; -function resolveSwagger(globalSettings, apiInfo, fileName, callback) { +function resolveSwagger(globalSettings, apiInfo, requestPath, fileName, callback) { debug('resolveSwagger(' + fileName + ')'); const FIVE_MINUTES = 5 * 60 * 1000; if (_swaggerMap[apiInfo.id]) { @@ -404,6 +404,10 @@ function resolveSwagger(globalSettings, apiInfo, fileName, callback) { injectTokenEndpoint(globalSettings, swaggerJson); } + swaggerJson.host = globalSettings.network.apiHost; + swaggerJson.basePath = requestPath; + swaggerJson.schemes = [globalSettings.network.schema]; + // Cache it for a while _swaggerMap[apiInfo.id] = { date: new Date(), @@ -478,7 +482,7 @@ apis.getSwagger = function (app, res, loggedInUserId, apiId) { // Read it, we want to do stuff with it. // resolveSwagger might read directly from the swagger file, or, if the // swagger JSON contains a href property, get it from a remote location. - resolveSwagger(globalSettings, apiInfo, swaggerFileName, (err, swaggerJson) => { + resolveSwagger(globalSettings, apiInfo, requestPath, swaggerFileName, (err, swaggerJson) => { if (err) { return res.status(500).json({ message: 'Could not resolve the Swagger JSON file, an error occurred.',