mirror of https://gitee.com/bigwinds/arangodb
Swagger models should reflect required properties.
This commit is contained in:
parent
53fbc02890
commit
74f7d0ee5e
|
@ -161,25 +161,26 @@ _.extend(Model, {
|
|||
if (this.prototype.schema) {
|
||||
_.each(this.prototype.schema, function (schema, attributeName) {
|
||||
var description = schema.describe(),
|
||||
type = description.type,
|
||||
jsonSchema = {type: description.type},
|
||||
rules = description.rules,
|
||||
flags = description.flags;
|
||||
|
||||
if (flags && flags.presence === 'required') {
|
||||
jsonSchema.required = true;
|
||||
required.push(attributeName);
|
||||
}
|
||||
|
||||
if (
|
||||
type === 'number' &&
|
||||
jsonSchema.type === 'number' &&
|
||||
_.isArray(rules) &&
|
||||
_.some(rules, function (rule) {
|
||||
return rule.name === 'integer';
|
||||
})
|
||||
) {
|
||||
type = 'integer';
|
||||
jsonSchema.type = 'integer';
|
||||
}
|
||||
|
||||
properties[attributeName] = {type: type};
|
||||
properties[attributeName] = jsonSchema;
|
||||
});
|
||||
} else {
|
||||
// deprecated
|
||||
|
|
Loading…
Reference in New Issue