active_model_serializers icon indicating copy to clipboard operation
active_model_serializers copied to clipboard

Serializer attribute keys not used in errors pointers.

Open bsylvain opened this issue 7 years ago • 4 comments
trafficstars

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"

bsylvain avatar Apr 16 '18 21:04 bsylvain

seems like an easy PR, no?

bf4 avatar Apr 17 '18 05:04 bf4

Is it unusual to use key? Maybe I missed something as this bug does not seems to bother anyone?

bsylvain avatar Mar 06 '19 16:03 bsylvain

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 :)

bf4 avatar Mar 07 '19 03:03 bf4

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.

bsylvain avatar Nov 14 '19 17:11 bsylvain