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'