-
Notifications
You must be signed in to change notification settings - Fork 79
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
Fixes and addition in InputMessegeContent and Parser modules #33
base: master
Are you sure you want to change the base?
Conversation
What's the problem if optional fields of |
If its nil and not used then you get error message like that: |
this is response from server when it's nil
and params are like that |
Well, instead of using empty string for optional field, I prefer to remove nil fields in request params. |
I do not quite understand where to do it: in |
I think this issue relates to this line: https://github.com/zhyu/nadia/blob/master/lib/nadia.ex#L635 Only nil field in the top level has been removed, a nil field in a non-nil field will not been removed. %{nil_field: nil, non_nil_field: %{nil_field: nil, non_nil_field: "something"}} will be changed to %{non_nil_field: %{nil_field: nil, non_nil_field: "something"}} if we change it to %{non_nil_field: %{non_nil_field: "something"}} there won't be any problem. So I think removing nil fields recursively will be a solution. |
not sure that is right solution) |
wdyt? |
lib/nadia/api.ex
Outdated
if !is_nil(file_field) and File.exists?(params[file_field]) do | ||
build_multipart_request(params, file_field) | ||
else | ||
{:form, params} | ||
end | ||
end | ||
|
||
defp drop_nil_fields(value) when is_list(value) do | ||
value | ||
|> Enum.map(fn value -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use a map?
defp drop_nil_fields(value) when is_list(value), do: Enum.map(value, drop_nil_fields)
The result should look something like this?
EDIT: no, this is not working |
in
EDIT: |
so like this? test go fine, but i have a problem with this
|
if i get it right |
07b5648
to
a621996
Compare
how about that? |
only problem is that |
i could add |
any thoughts? |
Sorry for keeping you waiting 😿 |
np, i'm glad you are back :) will look at this asap |
Thanks for your reply, please take your time 😺 |
Bug fix in
Nadia.Model.InputMessegeContent
module where optional fields must be string instead of nilFixes and additions in
Nadia.Parser
after the new models were introduced