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 for dasherized/hyphenized member names #11

Open
vovimayhem opened this issue Feb 7, 2018 · 2 comments
Open

Support for dasherized/hyphenized member names #11

vovimayhem opened this issue Feb 7, 2018 · 2 comments

Comments

@vovimayhem
Copy link

Currently, the payload validators expect member names to be underscored only.

When presented with a payload using either hyphens or spaces (although that's not recommended) which are allowed in the spec, the payload validator will fail.

@vovimayhem
Copy link
Author

vovimayhem commented Feb 7, 2018

IF we define the keys using strings with hyphens:

JsonapiSpecHelpers::Payload.register :person do
  key 'first-name'
end

Will make the assertions fail with this exception:

Failure/Error: assert_payload :person, test_person, json_items(0)

     NoMethodError:
       undefined method `first-name' for #<Person:0x0000559cd2ce7628>
       Did you mean?  first_name
                      first_name?
                      first_name=

So, I think I can do something with JsonapiSpecHelpers::Payload#key for this to work for everybody :) I'll send a PR

@ollizeyen
Copy link

ollizeyen commented Sep 6, 2021

I've added another try on solving this issue in #24. Please have a look and tell me what you think, @richmolj! Would be great to merge this one since I really need this and don't want to fork.

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

No branches or pull requests

2 participants