Skip to content

aliased attribute name will produce incorrect errors #104

Open

Description

@bsylvain

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.

Activity

  1. beauby commented on Mar 8, 2019

    @beauby
    Member

    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

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