https://github.com/ApplaudSolutions/mbaas/issues/514 - stripping tenantId from custom model routes

This commit is contained in:
ram33 2017-10-02 15:23:45 +05:30
parent c6072c70d8
commit a74aa6754e
1 changed files with 5 additions and 2 deletions

View File

@ -140,9 +140,12 @@ function mountSwagger(loopbackApplication, swaggerApp, opts) {
if (swaggerObject && swaggerObject.paths) {
var filteredSwaggerObject = JSON.parse(JSON.stringify(swaggerObject));
filteredSwaggerObject.paths = _.pickBy(swaggerObject.paths, function(val, key) {
filteredSwaggerObject.paths = _.reduce(_.pickBy(swaggerObject.paths, function(val, key) {
return key.indexOf(swaggerFilterPath) === 0;
});
}), function(result, val, key) {
result[key.replace(tenantId + '-', '')] = val;
return result;
}, {});
res.status(200).send(filteredSwaggerObject);
} else {
res.status(200).send(swaggerObject);