diff --git a/js/server/modules/org/arangodb/foxx/request_context.js b/js/server/modules/org/arangodb/foxx/request_context.js index b40f3a6d77..4d5ea02471 100644 --- a/js/server/modules/org/arangodb/foxx/request_context.js +++ b/js/server/modules/org/arangodb/foxx/request_context.js @@ -35,7 +35,7 @@ var SwaggerDocs = require("org/arangodb/foxx/swaggerDocs").Docs, internal = require("org/arangodb/foxx/internals"), toJSONSchema = require("org/arangodb/foxx/schema").toJSONSchema, is = require("org/arangodb/is"), - BadRequest = require("http-errors").BadRequest, + UnprocessableEntity = require("http-errors").UnprocessableEntity, UnauthorizedError = require("org/arangodb/foxx/authentication").UnauthorizedError; function createBodyParamExtractor(rootElement, paramName, allowInvalid) { @@ -101,7 +101,7 @@ function validateOrThrow(raw, schema, allowInvalid) { } var result = joi.validate(raw, schema); if (result.error && !allowInvalid) { - throw new BadRequest(result.error.message.replace(/^"value"/, 'Request body')); + throw new UnprocessableEntity(result.error.message.replace(/^"value"/, 'Request body')); } return result.value; } diff --git a/js/server/tests/shell-foxx.js b/js/server/tests/shell-foxx.js index 417a7f204f..0a9c563428 100644 --- a/js/server/tests/shell-foxx.js +++ b/js/server/tests/shell-foxx.js @@ -982,7 +982,7 @@ function DocumentationAndConstraintsSpec () { callback(req, res); assertFalse(called); - assertEqual(res.responseCode, 400); + assertEqual(res.responseCode, 422); }, testSetParamForUndocumentedBodyParam: function () {