Fixes and addition in InputMessegeContent and Parser modules#33
Fixes and addition in InputMessegeContent and Parser modules#33anronin wants to merge 2 commits intozhyu:masterfrom
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
|
|
||
| defp drop_nil_fields(value) when is_list(value) do | ||
| value | ||
| |> Enum.map(fn value -> |
There was a problem hiding this comment.
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.InputMessegeContentmodule where optional fields must be string instead of nilFixes and additions in
Nadia.Parserafter the new models were introduced