From ca4878b521c4d5eb4ac749a8fdf3cec78df54dd3 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Fri, 15 Sep 2017 10:44:45 -0700 Subject: [PATCH 1/4] Refresh swagger on remoteMethodAdded See https://github.com/strongloop/loopback-component-explorer/pull/208 --- index.js | 7 +++++++ test/explorer.test.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/index.js b/index.js index 21a8e8f..1d4d138 100644 --- a/index.js +++ b/index.js @@ -116,6 +116,13 @@ function mountSwagger(loopbackApplication, swaggerApp, opts) { swaggerObject = createSwaggerObject(loopbackApplication, opts); }); + // listening to started event for updating the swaggerObject + // when a call to app.models.[modelName].nestRemoting([modelName]) + // to appear that method in the Swagger UI. + loopbackApplication.on('remoteMethodAdded', function() { + swaggerObject = createSwaggerObject(loopbackApplication, opts); + }); + // listening to remoteMethodDisabled event for updating the swaggerObject // when a remote method is disabled to hide that method in the Swagger UI. loopbackApplication.on('remoteMethodDisabled', function() { diff --git a/test/explorer.test.js b/test/explorer.test.js index dba4099..a3e0db4 100644 --- a/test/explorer.test.js +++ b/test/explorer.test.js @@ -359,6 +359,41 @@ describe('explorer', function() { }); }); + it('updates swagger object when a remote method is added', function(done) { + var app = loopback(); + app.set('remoting', { cors: false }); + configureRestApiAndExplorer(app, '/explorer'); + + // Ensure the swagger object was built + request(app) + .get('/explorer/swagger.json') + .expect(200) + .end(function(err, res) { + if (err) return done(err); + + // Check the method that will be disabled + var paths = Object.keys(res.body.paths); + expect(paths).to.contain('/products/findOne'); + + var Product = app.models.Product; + Product.findOne2 = function(cb) { cb(null, 1); }; + Product.remoteMethod('findOne2', {}); + + // Request swagger.json again + request(app) + .get('/explorer/swagger.json') + .expect(200) + .end(function(err, res) { + if (err) return done(err); + + var paths = Object.keys(res.body.paths); + expect(paths).to.contain('/products/findOne2'); + + done(); + }); + }); + }); + function givenLoopBackAppWithExplorer(explorerBase) { return function(done) { var app = this.app = loopback(); From 51d1dc71b982190009f37836dbfbcfa6bebe3694 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Fri, 15 Sep 2017 11:01:31 -0700 Subject: [PATCH 2/4] 4.3.0 * Refresh swagger on remoteMethodAdded (Raymond Feng) --- CHANGES.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 018fa52..ab2a373 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +2017-09-15, Version 4.3.0 +========================= + + * Refresh swagger on remoteMethodAdded (Raymond Feng) + + 2017-03-24, Version 4.2.0 ========================= diff --git a/package.json b/package.json index 8c0ac85..f046237 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "loopback-component-explorer", - "version": "4.2.0", + "version": "4.3.0", "description": "Browse and test your LoopBack app's APIs", "engines": { "node": ">=4" From 37efa10e8e5fa73001458490cefb1558e427a90f Mon Sep 17 00:00:00 2001 From: Jee Mok Date: Thu, 10 May 2018 16:01:27 +0900 Subject: [PATCH 3/4] Fix lodash vulnerability: Prototype Pollution Ref: https://nodesecurity.io/advisories/577 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f046237..b8b531a 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "cors": "^2.7.1", "debug": "^2.2.0", "depd": "^1.1.0", - "lodash": "^3.10.0", + "lodash": "^4.17.5", "loopback-swagger": "^3.0.1", "strong-globalize": "^2.6.2", "swagger-ui": "^2.2.5" From f6faa8d7b3acc57b5b5857549db3a94bf6c8804a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Thu, 10 May 2018 09:33:08 +0200 Subject: [PATCH 4/4] 4.3.1 * Fix lodash vulnerability: Prototype Pollution (Jee Mok) --- CHANGES.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index ab2a373..b3b67af 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +2018-05-10, Version 4.3.1 +========================= + + * Fix lodash vulnerability: Prototype Pollution (Jee Mok) + + 2017-09-15, Version 4.3.0 ========================= diff --git a/package.json b/package.json index b8b531a..af623eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "loopback-component-explorer", - "version": "4.3.0", + "version": "4.3.1", "description": "Browse and test your LoopBack app's APIs", "engines": { "node": ">=4"