From b84f4c03d5cff2239fc5405f16b806a7c201a97a Mon Sep 17 00:00:00 2001 From: Tushar Gupta Date: Tue, 30 Oct 2018 15:53:15 +0530 Subject: [PATCH] ApplaudSolutions/applaud-cloud#1222 fix swagger API tab showing multiple models --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index fbd0a3d..ef62cfb 100644 --- a/index.js +++ b/index.js @@ -151,7 +151,10 @@ function mountSwagger(loopbackApplication, swaggerApp, opts) { if (swaggerObject && swaggerObject.paths) { var filteredSwaggerObject = JSON.parse(JSON.stringify(swaggerObject)); filteredSwaggerObject.paths = _.reduce(_.pickBy(swaggerObject.paths, function(val, key) { - return (key === swaggerFilterPath || key.startsWith(swaggerFilterPath + '/')); + if (req.query && req.query.model) { + return (key === swaggerFilterPath || key.startsWith(swaggerFilterPath + '/')); + } + return key.indexOf(swaggerFilterPath) === 0; }), function(result, val, key) { const tempKey = key.substring(key.indexOf(tenantId)); const index = (tempKey.indexOf('/') > -1) ? (tempKey.indexOf('/') + 1) : (tempKey.length);