1
0
Fork 0

Also respect required props in legacy schemas. Fixes #1097.

This commit is contained in:
Alan Plum 2014-11-18 11:30:10 +01:00 committed by Frank Celler
parent 0dbb3f3bf6
commit a39d48cd0f
1 changed files with 5 additions and 2 deletions

View File

@ -184,16 +184,19 @@ _.extend(Model, {
} else {
// deprecated
_.each(this.attributes, function (attribute, attributeName) {
var jsonSchema = {};
if (typeof attribute === 'string') {
properties[attributeName] = {type: attribute};
jsonSchema.type = attribute;
} else if (attribute) {
if (typeof attribute.type === 'string') {
properties[attributeName] = {type: attribute.type};
jsonSchema.type = attribute.type;
}
if (attribute.required) {
required.push(attributeName);
jsonSchema.required = true;
}
}
properties[attributeName] = jsonSchema;
});
}