add $ref and remove type for models
This commit is contained in:
parent
fa0c8d160a
commit
27e5895aa5
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
var _cloneDeep = require('lodash.clonedeep');
|
||||
var translateDataTypeKeys = require('./translate-data-type-keys');
|
||||
var TYPES_PRIMITIVE = ['array', 'boolean', 'integer', 'number', 'null', 'object', 'string'];
|
||||
|
||||
/**
|
||||
* Export the modelHelper singleton.
|
||||
|
@ -83,6 +84,11 @@ var modelHelper = module.exports = {
|
|||
// Change mismatched keys.
|
||||
prop = translateDataTypeKeys(prop);
|
||||
|
||||
if (TYPES_PRIMITIVE.indexOf(prop.type) === -1 ){
|
||||
prop.$ref = prop.type;
|
||||
delete prop.type;
|
||||
}
|
||||
|
||||
// Assign this back to the properties object.
|
||||
properties[key] = prop;
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ describe('model-helper', function() {
|
|||
address: Address
|
||||
});
|
||||
var prop = def.properties.address;
|
||||
expect(prop).to.eql({ type: 'Address' });
|
||||
expect(prop).to.eql({ $ref: 'Address' });
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue