Closed matt-glover closed 1 year ago
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.
Cool. I'll take a pass at enhancing the spec flow early next week and share what I come up with.
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.