active_model_serializers
active_model_serializers copied to clipboard
Adjusts Deserializer relationship parsing to allow links/meta keys
Purpose
The JSON API spec allows for the relationships key to include one of data, links or meta.
The current parsing logic for the deserialiser raises an exception unless a data key is present (this may have been changed after the code was written 🚄), which means that we're getting an exception on a valid JSON:API document 😭
Changes
- Adjusts the document validation inside the Deserializer to allow for one of
data,links, ormetaas per the spec. - Ignores the
linksormetakeys when parsing the relationship into something to be used by Rails.
Caveats
It may not be the best behaviour to ignore the keys silently - however, I'm not really sure what a useful thing to do here would be. Perhaps print a warning?
Related GitHub issues
None 😺
Additional helpful information
Thanks for the 💎, and your time reviewing this folks!
@beauby any objections?
@bf4 I think this still a change that's needed - is there a reason why you closed the PR? I'm not sure the test failures are related to the changes I've made but I could update to latest 0-10-stable and attempt to get them passing?
@nikz Not sure how or why I closed it
@bf4 slip of the mouse! No worries at all. Is there anything you need me to do on this patch?
I think I'd rather replace our deserializer with the jsonapi-deserializer. There are prs for it. See https://github.com/rails-api/active_model_serializers/pull/1928#issuecomment-298298106