This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-23
Channels
- # 100-days-of-code (1)
- # adventofcode (13)
- # aleph (1)
- # beginners (48)
- # boot (10)
- # calva (52)
- # cider (18)
- # cljsrn (23)
- # clojure (68)
- # clojure-uk (9)
- # clojurescript (5)
- # cursive (3)
- # datomic (4)
- # figwheel (7)
- # fulcro (14)
- # hoplon (2)
- # leiningen (5)
- # lumo (3)
- # off-topic (87)
- # overtone (5)
- # reitit (5)
- # rum (8)
- # shadow-cljs (7)
- # spacemacs (15)
hi - anyone know how i can specify an optional query parameter? i'm using spec coercion
here's my route definition:
["/animals"
{:get
{:summary "retrieving animals"
:parameters {:query {:name string?}}
:responses {200 {:schema ::animals-response}}
:handler (fn [{{name :name} :query-params}]
(to-http (if name
(animals/animals animal-repo name)
(animals/animals animal-repo))))}}]
i want the :name
parameter to be optional here. i've tried a few different options - using s/or
, s/nilable
, etc, but it still shows up in swagger as required
@mike706574 {(ds/opt :name) string?}
, given (require '[spec-tools.data-spec :as ds])
. Another option is to use s/keys
with :opt
or :opt-un
keys.