diff --git a/lib/model-helper.js b/lib/model-helper.js index 51fbf53..598f0f1 100644 --- a/lib/model-helper.js +++ b/lib/model-helper.js @@ -121,9 +121,12 @@ var modelHelper = module.exports = { if (typeof propType === 'function') { // See https://github.com/strongloop/loopback-explorer/issues/32 // The type can be a model class - propType = propType.modelName || propType.name.toLowerCase(); - } else if(Array.isArray(propType)) { - propType = 'array'; + return propType.modelName || propType.name.toLowerCase(); + } else if (Array.isArray(propType)) { + return 'array'; + } else if (typeof propType === 'object') { + // Anonymous objects, they are allowed e.g. in accepts/returns definitions + return 'object'; } return propType; }, diff --git a/test/model-helper.test.js b/test/model-helper.test.js index b183400..1fb6414 100644 --- a/test/model-helper.test.js +++ b/test/model-helper.test.js @@ -214,6 +214,13 @@ describe('model-helper', function() { expect(def.properties).to.have.property('visibleProperty'); }); }); + + describe('getPropType', function() { + it('converts anonymous object types', function() { + var type = modelHelper.getPropType({ name: 'string', value: 'string' }); + expect(type).to.eql('object'); + }); + }); }); // Simulates the format of a remoting class.