-
Notifications
You must be signed in to change notification settings - Fork 148
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
Fields filters should be underscored #193
Comments
@alanpeabody there is no default naming as far as I know http://jsonapi.org/format/#document-member-names so I would like to see by default use Specially when most of the programming languages are easier to read from Could we default the attributes name to
in my configuration in every single project that use this |
@yordis the default naming is what jsonapi.org recommends: http://jsonapi.org/recommendations/#naming |
😭 I guess I will continue using the code snippet |
sorry. :-/ |
@alanpeabody @yordis I am not sure you got the exact issue I have with this. As per JSONAPI spec
Thing is when I pass multiple words separated by
because actually there is no defp safe_atom_list(field_str) do
field_str |> String.replace("-", "_") |> String.split(",") |> Enum.map(&String.to_existing_atom/1)
end I am just not sure if this is the best solution :) |
@zlatio yeah, I understand your issue. To be frank I don't know the best solution. Currently the formatting of the keys all happens here: https://github.com/vt-elixir/ja_serializer/blob/master/lib/ja_serializer/param_parser.ex However it is impractical/incorrect to format values there. The piece your solution is missing is a way to customize it... If we hooked into |
True, there is no way to customize it. I will try to come up with a PR for this :) |
Thanks a bunch! |
I think the handling is inconsistent through out if by default inserted_at is being serialized to "inserted-at" then the generated templates should also handle the input the same way. I believe ParamParser should be called inside Params.to_attributes because Params.to_attributes is taking care of parsing relationships which is a json-api spec so then it should also take care of translating the keys. I will open up a new issue for this. |
Hello,
First of all thank you for this library :) I think it's great. However I have one issue. When passing fields parameter like
fields[users]=first-name,last-name
I getargument_error
Attributes filters needs to be underscored because otherwise they can't be converted to existing atoms. So in the attribute builder on line 31 we need something like this:
What do you think?
The text was updated successfully, but these errors were encountered: