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

aliased attribute name will produce incorrect errors #104

Open
bsylvain opened this issue Mar 8, 2019 · 1 comment
Open

aliased attribute name will produce incorrect errors #104

bsylvain opened this issue Mar 8, 2019 · 1 comment

Comments

@bsylvain
Copy link

bsylvain commented Mar 8, 2019

The error pointer do not match the alias used in the serializer.

serializer :

attribute :reply do
  @object.content
end

response when there is an active record error :
{"errors":[{"title":"Invalid content","detail":"Nouveau commentaire est trop court (au moins 16 caractères)","source":{}}],"jsonapi":{"version":"1.0"}}

Ideally source should contain a pointer to reply.
I am not sure If it is possible to correctly alias the error with the declaration done in a bloc.

@beauby
Copy link
Member

beauby commented Mar 8, 2019

The errors are set by the deserializer, which are independent from the serializers. The deserializable module maintains a reverse mapping for renamed keys, which is used to generate the JSON pointer.

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