This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-08
Channels
- # announcements (1)
- # babashka (28)
- # beginners (30)
- # calva (1)
- # cider (13)
- # clojure (26)
- # clojure-brasil (2)
- # clojure-europe (29)
- # clojure-italy (1)
- # clojure-nl (1)
- # clojure-norway (16)
- # clojure-spec (4)
- # clojure-uk (5)
- # cursive (17)
- # data-science (15)
- # datomic (8)
- # emacs (8)
- # events (1)
- # hyperfiddle (54)
- # joyride (18)
- # jvm (2)
- # kaocha (8)
- # lsp (8)
- # malli (4)
- # missionary (11)
- # reagent (5)
- # reitit (13)
- # releases (2)
- # rum (2)
- # scittle (6)
- # shadow-cljs (3)
Using malli to pass http requests can you have a sequence of query parameters, someone else asked here https://clojurians.slack.com/archives/CLDK6MFMK/p1637852630157700 with no answer, seems swagger is happy in that you can add them to query params as comma separated values but when the request is made malli return's invalid type on the vector, should this work ? I am seeing the same behavior as @haiyuan.vinurs
Not sure about the swagger and parsing part, but ring middleware usually converts duplicate query params into collections:
(let [app (ring/ring-handler
(ring/router
["/ping" {:get #(select-keys % [:params :query-params])}]
{:data {:middleware [parameters/parameters-middleware]}}))]
(is (= {:query-params {"kikka" "0"}
:params {"kikka" "0"}}
(app {:request-method :get
:uri "/ping"
:query-string "kikka=0"})))
(is (= {:query-params {"kikka" ["0" "1"]}
:params {"kikka" ["0" "1"]}}
(app {:request-method :get
:uri "/ping"
:query-string "kikka=0&kikka=1"}))))
FWIW there's a related issue about spec + parsing here: https://github.com/metosin/reitit/issues/298
nice find I notice when testing in swagger it actually setup the query as ?key=value1,value2 so its comma separating perhaps I will add that to the issue, as the above shows & as a separator