Closed take-five closed 7 years ago
Hi @take-five , This is intentional. It's suitable in my case and I followed this guide Null_Property_Values. Could you please show me your case used it?
I'm designing a simple REST API which supports CRUD operations. Let's say, I want to update user information via REST API. "phone" column can have null
values, it's a legacy DB and I can't change it. So how do I set "phone" to null
via REST API? I can pass empty string, but that's very confusing for API user.
Also, I guess Google guide refers mostly to JSON response rather than request
how about decide whether keep it by an option like this:
when I pass {"phone": null}
to endpoint, optional :phone, keep_blank: true
will get %{phone: nil}
and optional :phone
will get %{}
?
Sounds like a good plan. Will optional :phone, keep_blank: true
implicitly set parameter to nil
if it wasn't passed? I believe it shouldn't.
It shouldn't.
Hello!
I wanted to give Elixir a try and tried to implement very simple JSON API using Maru. Maru is looking good for me at the moment, but I've found strange behavior recently.
Here is Maru router which describes what I've found:
I expect that this endpoint will return a JSON containing exact value of given
phone
param. It works in most cases:But if I pass "null" value,
maru
will discard this parameter completely:This behaviour restricts JSON API very much, so as an API designer I can't provide ability to use
null
values for certain keys (which is necessary in my case).Is this intentional or is it a bug? Thanks :)