Return source pointer '/data/attributes' if attribute was not supplied in payload#94
Return source pointer '/data/attributes' if attribute was not supplied in payload#94JoeWoodward wants to merge 1 commit intojsonapi-rb:masterfrom
Conversation
94965a5 to
3c197dd
Compare
|
Should we override the error description if the pointer is missing? http://jsonapi.org/examples/#error-objects-source-usage the example here returns a description "detail": "Missing data Member at document's top level." i.e. {
"errors": [
{
"detail": "Missing `name` Member at document's /data/attributes level",
"source": {
"pointer": "/data/attributes"
},
"meta": {
"detailed_error_message": {
"title": "Invalid name",
"detail": "Name cannot be blank"
}
}
}
],
"jsonapi": {
"version": "1.0"
}
}Maybe the meta is overkill. Probably enough to just override the detail and remote the title |
|
IIRC, the |
|
I think that's the issue though. The following is a valid payload Even if the logic was changed to consider this invalid we can still get null pointers with missing attributes. e.g. There is an issue with this PR though; The error isn't necessarily going to be from a member on Maybe there's a way to decipher the pointer from the AM::Errors hash. Need to look into it further |
This PR fixes the source pointer when the payload is missing a validated attribute.
e.g.
if we post
{ data: { attributes: {} } }We get back an error with an empty pointer
{ "errors": [ { "title": "Invalid name", "detail": "Name can't be blank", "source": {} } ], "jsonapi": { "version": "1.0" } }With this change we return the node where the attribute is missing from
{ "errors": [ { "title": "Invalid name", "detail": "Name can't be blank", "source": { "pointer": "/data/attributes" } } ], "jsonapi": { "version": "1.0" } }