Skip to content

Support for dasherized/hyphenized member names  #11

Open

Description

@vovimayhem

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.

Activity

  1. vovimayhem commented on Feb 7, 2018

    @vovimayhem
    Author

    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

  2. ollizeyen commented on Sep 6, 2021

    @ollizeyen

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions