model-helper: support anonymous object types
Accepts/returns arguments allow anonymous object types, e.g. { 'arg': 'kvp', type: { 'name': 'string', 'value': 'string' } } As of this commit, these types are converted to Swagger type 'object'.
This commit is contained in:
parent
aa7cb0b118
commit
9a6bd35df7
|
@ -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;
|
||||
},
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue