You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error in the title occurs if certain keys are present and others are missing from the JSON body when attempting to POST to an endpoint.
In my local example I setup a plug pipeline with the following JSON API plugs:
plugJSONAPI.EnsureSpecplugJSONAPI.Deserializer
I largely copied over the examples from the README to setup some views and wire those into a controller.
Once I called the route via curl I correctly got warnings from EnsureSpec for many different missing JSON keys.
Example:
{"errors":[{"detail":"Check out http://jsonapi.org/format/#crud for more info.","source":{"pointer":"/data/type"},"status":"400","title":"Missing type in data parameter"}]}
Once I partially/incorrectly defined a relationship the deserializer started to crash leading to a 500 error:
I'm happy to offer a PR to the deserializer flow to reduce the cases that crash in the face of malformed params like these. But I wanted to log an issue in case there's a preference for an alternate approach with this project like adding more EnsureSpec checks or something else.
The text was updated successfully, but these errors were encountered:
I think I like your idea of handling this with EnsureSpec as opposed to making other code handle more cases not representable by JSON:API. A tough call, but that's the way I think I lean.
The error in the title occurs if certain keys are present and others are missing from the JSON body when attempting to
POST
to an endpoint.In my local example I setup a plug pipeline with the following JSON API plugs:
I largely copied over the examples from the README to setup some views and wire those into a controller.
Once I called the route via curl I correctly got warnings from
EnsureSpec
for many different missing JSON keys.Example:
Once I partially/incorrectly defined a relationship the deserializer started to crash leading to a 500 error:
I'm happy to offer a PR to the deserializer flow to reduce the cases that crash in the face of malformed params like these. But I wanted to log an issue in case there's a preference for an alternate approach with this project like adding more
EnsureSpec
checks or something else.The text was updated successfully, but these errors were encountered: