This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-20
Channels
- # announcements (1)
- # asami (6)
- # babashka (21)
- # beginners (19)
- # calva (44)
- # circleci (3)
- # clj-http (3)
- # clj-kondo (44)
- # clojure (24)
- # clojure-australia (1)
- # clojure-czech (1)
- # clojure-europe (50)
- # clojure-france (5)
- # clojure-germany (1)
- # clojure-nl (2)
- # clojure-spec (8)
- # clojure-uk (8)
- # clojurescript (161)
- # datomic (4)
- # fulcro (7)
- # graalvm (8)
- # heroku (4)
- # lambdaisland (4)
- # lein-figwheel (5)
- # lsp (48)
- # malli (21)
- # meander (15)
- # off-topic (35)
- # polylith (2)
- # re-frame (21)
- # react (22)
- # reagent (13)
- # reitit (6)
- # remote-jobs (1)
- # reveal (3)
- # ring (3)
- # shadow-cljs (37)
- # testing (2)
- # tools-deps (10)
- # vim (18)
- # vrac (1)
- # xtdb (17)
Hi, I might be missing something obvious, but how can I make query parameters optional in reitit.coercion.spec/coercion
? i.e. I'd like to accept both requests to /images
but also /images?subject=cat
. Something like :query {:subject (s/nilable string?)}
still just gives a 400 bad request because :subject
is a required key.
I think you could use :req-un
and :opt-un
keys with spec coercion
^^ Indeed. It wasn’t immediately intuitive to me either, but this works
(s/def ::param boolean?)
(s/def ::optional-params
(s/keys :opt-un [::param]))
["/your-route"
{:name :blah
:parameters {:query ::optional-params}}]
"/your-route?param=true"