Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support deserialization for data collections #68

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rdnewman
Copy link

@rdnewman rdnewman commented Sep 29, 2021

What is the current behavior?

When deserializing (via JSON::Deserialization, #jsonapi_deserialize.call) a document where :data is an array of resources, it fails because it assumes a single resource. The error occurs on Line 52 of jsonapi.rb/lib/jsonapi/deserialization.rb.

What is the new behavior?

jsonapi_deserialize.call now supports cases where :data is an array. Each element of the array will be deserialized in the same manner as when :data is a single resource. Cases where :data is not an array are unchanged.

Checklist

Please make sure the following requirements are complete:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes /
    features)
  • All automated checks pass (CI/CD)

},
second_author: {
data: nil

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deserialization spec is pretty long now and I'm sure it could be DRYed out a fair amount (shared examples look promising though most of the length is specifying the data), but wanted to follow existing convention as it was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant