I would like to utilize comma-separated query parameters instead of repeating the key for each element, i.e. ?foo=bar,baz
instead of ?foo=bar&foo=baz
. I haven't been able to find any configuration option or obvious examples over a few Google queries. Does anyone have any experience with trying this? Or should I just accept the defaults as they are 😅
I use comma separated queries
Basically I have this:
(def paging [:map
{:closed true}
[:limit {:optional true :default 25} [:int {:min 0 :max 100}]]
[:page {:optional true :default 0} [:int {:min 0 :max 500}]]
[:sort {:optional true} [:enum {:swagger/type "string"} "asc" "desc"]]
[:sort-fields {:optional true} string?]
[:fields {:optional true} string?]])
fields
is just a string..
then when I process it...
(let [{{{:keys [ fields]} :query} :parameters} request]
{:fields (when-not (clojure.string/blank? fields) (clojure.string/split fields ",")}
I end up with a :fields
key in a map with [bar baz]
process then as you see fit 🙂
btw, I use malli
in your case, :fields
would be :foo
okay, I figured something like that would work, I was just hoping there was a built in way to have reitit coerce things nicely just in [:parameters :query]
not aware of anything 😉 Supaar simple to do oneself, tho 🙂
maybe, worth a try
if you were to change the spec to be :fields {optional true} [:vector string?]
that may coerce it into a vector?
give it a shot
I already have the spec defined as a vector, but the only way it coerces right now is if I pass them in like ?foo=bar&foo=baz
k