handle excludeBaseProperties
This commit is contained in:
parent
d375d61519
commit
52f8fb3416
|
@ -256,8 +256,18 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett
|
|||
ModelClass.setter = {};
|
||||
|
||||
for (var p in properties) {
|
||||
// Remove properties that reverted by the subclass
|
||||
if (properties[p] === null || properties[p] === false) {
|
||||
// e.g excludePropertyList = ['id'] - base properties listed in excludePropertyList will be excluded from the model.
|
||||
// excludeBaseProperties is introduced in SOAP model generation only for now and below logic
|
||||
// handles excludeBaseProperties. Generated SOAP model has base as 'Model' which means 'id' property gets added
|
||||
// automatically and 'id' property shouldn't be there for SOAP models. idInjection = false will not work
|
||||
// for SOAP generator case, since base 'Model' has already id property. 'id: false' at the property level will not
|
||||
// work either for SOAP generator case since generators use ModelDefinition.create to create property in the model
|
||||
// dynamically, that execution path has strict validation where doesn't accept 'id: false' in a property.
|
||||
// See https://github.com/strongloop/loopback-workspace/issues/486 for some more details.
|
||||
var excludePropertyList = settings['excludeBaseProperties'];
|
||||
// Remove properties that reverted by the subclass of the property from excludePropertyList
|
||||
if (properties[p] === null || properties[p] === false ||
|
||||
(excludePropertyList != null && excludePropertyList.indexOf(p) != -1)) {
|
||||
// Hide the base property
|
||||
delete properties[p];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue