Skip to content

Commit

Permalink
Fixes regression bug Haufe-Lexware/wicked.haufe.io#99
Browse files Browse the repository at this point in the history
With the implementation of the href referencing, the overwriting of host, basePath and schemes was lost. Dammit.
  • Loading branch information
DonMartin76 committed Jan 13, 2018
1 parent 9ab5f7b commit 7f351f0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions routes/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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.',
Expand Down

0 comments on commit 7f351f0

Please sign in to comment.