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

Allways transform rel_name to underscore #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kennstenicht
Copy link

What is the current behavior?

If i set set_key_transform :dash in my serializer all keys, including the relationship names are dasherized. But relationships with dasherized names are exluded if "only" or "except" option is set, because params inside the only or except options needs to be underscore.

What is the new behavior?

Now I am able to define the parms inside my option in dasherized or any other format.
jsonapi_deserialize(params, only: [dasherized-relation-name])

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)

@stas
Copy link
Owner

stas commented Feb 22, 2021

Thanks @kennstenicht

I'd like to merge it, but I think we should make the whole deserialization support pluggable.
We have the #5 related to this.

Let me know if you have time to continue the work on it. 🙇

@@ -62,7 +62,7 @@ def jsonapi_deserialize(document, options = {})

relationships.map do |assoc_name, assoc_data|
assoc_data = (assoc_data || {})['data'] || {}
rel_name = jsonapi_inflector.singularize(assoc_name)
rel_name = jsonapi_inflector.singularize(assoc_name).underscore
Copy link
Owner

Choose a reason for hiding this comment

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

@kennstenicht we will want to call the jsonapi_inflector.underscore separately, otherwise non-rails usage will not be supported.

@stas stas added this to the v1.8 milestone Sep 1, 2021
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.

2 participants