This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-17
Channels
- # bangalore-clj (2)
- # beginners (202)
- # boot (18)
- # cljs-dev (8)
- # cljsjs (7)
- # cljsrn (4)
- # clojars (2)
- # clojure (401)
- # clojure-boston (2)
- # clojure-dusseldorf (1)
- # clojure-gamedev (36)
- # clojure-greece (2)
- # clojure-italy (1)
- # clojure-russia (16)
- # clojure-spec (27)
- # clojure-uk (7)
- # clojurescript (68)
- # core-async (16)
- # cursive (25)
- # datascript (1)
- # datomic (34)
- # funcool (1)
- # hoplon (1)
- # interop (1)
- # klipse (1)
- # leiningen (2)
- # lumo (75)
- # off-topic (17)
- # om-next (2)
- # onyx (66)
- # re-frame (18)
- # reagent (2)
- # ring-swagger (11)
- # spacemacs (1)
- # specter (1)
- # timbre (3)
- # untangled (48)
- # yada (7)
How to deal with defaults for optional query parameters in Yada? In Compojure-API we used that letk syntax. Now I’m doing it like this:
{:swagger/tags [“articles”]
:methods
{:get
{:parameters
{:query {(s/optional-key :source) s/Bool
(s/optional-key :annotation) s/Bool
(s/optional-key :skip-classification) s/Bool}}
:swagger/summary “Get an article by GUID”
:response (fn [ctx]
(let [parameters (-> ctx :parameters :query)
{:keys [source annotation skip-classification]
:or {source false
annotation false
skip-classification false}}
parameters]
))}}}
@borkdude you can also use select-keys
, and then merge
those into some default values
Schema doesn’t handle defaults by default either, but there is a helper for those in schema-tools (https://github.com/metosin/schema-tools/blob/master/test/schema_tools/core_test.cljc#L235-L242)