You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(From #reitit on slack clojurians)
I recently had a question about documenting and filling in default values when using Malli.
I found this example code
["/plus"
{[..]
:post {:summary "plus with malli body parameters"
:parameters {:body [:map
[:x
{:title "X parameter"
:description "Description for X parameter"
:json-schema/default 42}
int?]
[:y int?]]}
I believed that I could omit x from the request since it has a :json-schema/default defined: http :3000/math/plus y:=5
but that leads to the error: "x": ["missing required key"]
I eventually discovered that my desired behavior could be achieved by changing the key name from :json-schema/default to :default.
It would be nice to have this documented.
Of course, :default is what Malli uses, but to get Malli to fill in default values, some more work needs to be done. It wasn't apparent to me to which extent reitit would assist here. Quite a lot, it turns out.
If this seems reasonable, I will be happy to submit a PR.
Thank you for all the great libraries!
The text was updated successfully, but these errors were encountered:
(From #reitit on slack clojurians)
I recently had a question about documenting and filling in default values when using Malli.
I found this example code
reitit/examples/ring-malli-swagger/src/example/server.clj
Line 75 in 77e2b56
I believed that I could omit x from the request since it has a :json-schema/default defined:
http :3000/math/plus y:=5
but that leads to the error:
"x": ["missing required key"]
I eventually discovered that my desired behavior could be achieved by changing the key name from
:json-schema/default
to:default
.It would be nice to have this documented.
Of course,
:default
is what Malli uses, but to get Malli to fill in default values, some more work needs to be done. It wasn't apparent to me to which extent reitit would assist here. Quite a lot, it turns out.If this seems reasonable, I will be happy to submit a PR.
Thank you for all the great libraries!
The text was updated successfully, but these errors were encountered: