From 74f7d0ee5e1561ceafe1a76d394d6770fa5593cb Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Tue, 18 Nov 2014 11:21:08 +0100 Subject: [PATCH] Swagger models should reflect required properties. --- js/server/modules/org/arangodb/foxx/model.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/js/server/modules/org/arangodb/foxx/model.js b/js/server/modules/org/arangodb/foxx/model.js index 079b398929..d3c676ecb8 100644 --- a/js/server/modules/org/arangodb/foxx/model.js +++ b/js/server/modules/org/arangodb/foxx/model.js @@ -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