From 536fa4c5776e12a8badea084726938d3dd3ba3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Tue, 22 Jul 2014 21:52:25 +0200 Subject: [PATCH 1/2] model-helper: handle arrays with undefined items --- lib/model-helper.js | 2 +- test/model-helper.test.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/model-helper.js b/lib/model-helper.js index b818222..d165844 100644 --- a/lib/model-helper.js +++ b/lib/model-helper.js @@ -79,7 +79,7 @@ var modelHelper = module.exports = { out.type = modelHelper.getPropType(out.type); if (out.type === 'array') { - var hasItemType = typeof prop.type !== 'string' && prop.type.length; + var hasItemType = typeof prop.type !== 'string' && prop.type[0]; if (hasItemType) { var arrayProp = prop.type[0]; diff --git a/test/model-helper.test.js b/test/model-helper.test.js index e13da9f..d639390 100644 --- a/test/model-helper.test.js +++ b/test/model-helper.test.js @@ -89,6 +89,16 @@ describe('model-helper', function() { expect(prop).to.eql({ type: 'array' }); }); + it('converts [undefined] type', function() { + var def = getDefinition({ + // This value is somehow provided by loopback-boot called from + // loopback-workspace. + array: [undefined] + }); + var prop = def.properties.array; + expect(prop).to.eql({ type: 'array' }); + }); + it('converts "array" type', function() { var def = getDefinition({ array: 'array' From bb683e20a9a6ab3fcca18e34f622b8ccd8b66942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Tue, 22 Jul 2014 21:57:53 +0200 Subject: [PATCH 2/2] 1.2.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 998973b..46626d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "loopback-explorer", - "version": "1.2.3", + "version": "1.2.4", "description": "Browse and test your LoopBack app's APIs", "main": "index.js", "scripts": {