active_model_serializers
active_model_serializers copied to clipboard
Serializer attribute keys not used in errors pointers.
0.10.7
When validation errors occurs, the pointers does not use the keys from the serializer :
serializer :
attribute :ville,key: :city
JSON :
{"errors":[{"source":{"pointer":"/data/attributes/ville"},"detail":"doit être rempli(e)"}]}
The pointer should be "/data/attributes/city"
seems like an easy PR, no?
Is it unusual to use key? Maybe I missed something as this bug does not seems to bother anyone?
Someone just needs to write a failing test and fix it. I don't use AMS anymore, so I'm guessing it's bothering you more than me :)
I added a test to this file https://github.com/rails-api/active_model_serializers/blob/0-10-stable/test/action_controller/json_api/errors_test.rb
here : https://github.com/bsylvain/active_model_serializers/blob/0-10-stable/test/action_controller/json_api/errors_test.rb
I added two methods : test_active_model_with_an_error_in_a_key_attribute to make the actual test and render_resource_with_error_in_a_key to render a resource.
To complete the test it needs
attribute :comment, key: :title
To the profile_serializer
I have no idea how to do that in the tests.