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) {
|
if (this.prototype.schema) {
|
||||||
_.each(this.prototype.schema, function (schema, attributeName) {
|
_.each(this.prototype.schema, function (schema, attributeName) {
|
||||||
var description = schema.describe(),
|
var description = schema.describe(),
|
||||||
type = description.type,
|
jsonSchema = {type: description.type},
|
||||||
rules = description.rules,
|
rules = description.rules,
|
||||||
flags = description.flags;
|
flags = description.flags;
|
||||||
|
|
||||||
if (flags && flags.presence === 'required') {
|
if (flags && flags.presence === 'required') {
|
||||||
|
jsonSchema.required = true;
|
||||||
required.push(attributeName);
|
required.push(attributeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
type === 'number' &&
|
jsonSchema.type === 'number' &&
|
||||||
_.isArray(rules) &&
|
_.isArray(rules) &&
|
||||||
_.some(rules, function (rule) {
|
_.some(rules, function (rule) {
|
||||||
return rule.name === 'integer';
|
return rule.name === 'integer';
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
type = 'integer';
|
jsonSchema.type = 'integer';
|
||||||
}
|
}
|
||||||
|
|
||||||
properties[attributeName] = {type: type};
|
properties[attributeName] = jsonSchema;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// deprecated
|
// deprecated
|
||||||
|
|
Loading…
Reference in New Issue