diff --git a/CHANGELOG b/CHANGELOG index 30552d8bb7..94bcbe648e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -32,6 +32,8 @@ v2.3.0 (XXXX-XX-XX) * dynamically create extra dispatcher threads if required +* fixed issue #1097: schemas in the API docs no longer show required properties as optional + v2.3.0-beta2 (2014-11-08) ------------------------- diff --git a/js/server/modules/org/arangodb/foxx/model.js b/js/server/modules/org/arangodb/foxx/model.js index 079b398929..703eba25fd 100644 --- a/js/server/modules/org/arangodb/foxx/model.js +++ b/js/server/modules/org/arangodb/foxx/model.js @@ -161,39 +161,43 @@ _.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 _.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; }); } diff --git a/js/server/tests/shell-transactions-noncluster.js b/js/server/tests/shell-transactions-noncluster.js index 1359b2ffbd..db1b7a6e70 100644 --- a/js/server/tests/shell-transactions-noncluster.js +++ b/js/server/tests/shell-transactions-noncluster.js @@ -255,6 +255,27 @@ function transactionInvocationSuite () { } }, +//////////////////////////////////////////////////////////////////////////////// +/// @brief test: nesting +//////////////////////////////////////////////////////////////////////////////// + + testNestingEmbedFlag : function () { + var obj = { + collections : { + }, + action : function () { + return 19 + TRANSACTION({ + collections: { + }, + embed: true, + action: "function () { return 23; }" + }); + } + }; + + assertEqual(42, TRANSACTION(obj)); + }, + //////////////////////////////////////////////////////////////////////////////// /// @brief test: params ////////////////////////////////////////////////////////////////////////////////