Hi folks. Can anyone point me in the direction of defining a schema for a JSON body that has optional properties?
@d.marrs what coercion are you using? Schema, spec, data-spec or malli? All have different ways in doing that
@ikitommi schema. I've defined the params like so:
:parameters {
:body {
:a s/Str
:b s/Str
:c s/Str
:d s/Str
:e s/Bool
}}
I get a 400 error: `
"(not (map? nil))"
if you want to allow nil
body, you should wrap the body in s/maybe
. For optional props, use s/optional-key
, e.g.
(s/maybe {:a s/Str, (s/optional-key :b) s/Str})