inveniosoftware / invenio-records-rest

Invenio records REST API module.
https://invenio-records-rest.readthedocs.io
MIT License
4 stars 63 forks source link

Change validation error message when creating a record via the API #223

Closed dinosk closed 6 years ago

dinosk commented 6 years ago

Trying to create a test record I saw the following message:

$ curl -k -H "Content-type: application/json" -XPOST https://localhost:5000/api/records/ -d '{"title":"aaa1", "name":"test"}'
{"status": 400, "message": "Validation error.", "errors": [{"field": "name", "message": "Unknown field name name"}, {"field": "name", "message": "Missing data for required field."}]}%      

which doesn't mention that the required name field is inside the contributors field.

$ curl -k -H "Content-type: application/json" -XPOST https://localhost:5000/api/records/ -d '{"title":"aaa1", "contributors":[{"name": "Doe, John"}]}'
{"created"... works ok 
dinosk commented 6 years ago

Mentioned in https://github.com/marshmallow-code/marshmallow/issues/319 and fixed in https://github.com/marshmallow-code/marshmallow/pull/754, but wasn't included in 2.15.4 and it is planned for v3.