This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-07
Channels
- # aleph (3)
- # aws (7)
- # beginners (117)
- # boot (119)
- # cider (2)
- # cljs-dev (3)
- # clojure (193)
- # clojure-austin (1)
- # clojure-dusseldorf (4)
- # clojure-finland (5)
- # clojure-france (5)
- # clojure-italy (7)
- # clojure-portugal (1)
- # clojure-russia (204)
- # clojure-serbia (5)
- # clojure-spec (31)
- # clojure-uk (64)
- # clojurescript (288)
- # community-development (9)
- # core-async (54)
- # cursive (8)
- # datascript (18)
- # datomic (26)
- # dirac (8)
- # emacs (26)
- # figwheel (1)
- # hoplon (16)
- # jobs (2)
- # jobs-discuss (4)
- # juxt (1)
- # lein-figwheel (4)
- # leiningen (14)
- # london-clojurians (2)
- # lumo (17)
- # off-topic (44)
- # om (63)
- # om-next (2)
- # onyx (26)
- # perun (14)
- # planck (5)
- # portland-or (34)
- # proton (2)
- # protorepl (8)
- # quil (1)
- # re-frame (6)
- # reagent (16)
- # remote-jobs (4)
- # ring (7)
- # ring-swagger (10)
- # rum (1)
- # untangled (2)
@mrchance don't know any easy way, but it is doable. Needs custom transformations for docs, in & out. In & Out can be done with schema coercions, middleware or custom Muuntaja formatter. Docs can be transformed in a custom middleware before the swagger-routes. I would use fooBar
all the way down if that's the requirement for swagger
@ikitommi thanks! Yeah, that's how I solved it, not an issue, just a minor aesthetic itch 😉
I'm getting started with swaggerifying my routes, and I seem not to be able to find a particular use case in the docs. I'd like to define a schema (e.g. (s/defschema PageRequest [{:attributes :- [s/Str] ["uuid"]}])
) for query parameters and then plug that into my GET
's :query-params
, but query-params seems to want names instead of keys (e.g. [{attributes :- [s/Str] ["uuid"]}]
). Is there a conversion between these two schema representations that I'm missing?
@daveliepmann there is :query
and :query-params
. If you have a request-schema predefined, try the :query
.
and your example-schema should be something like (s/defschema PageRequest {:attributes [s/Str]}))
. Sadly, there is no default-handling in the Schema core itself.
the plumbing fnk has the notation of default, someone should integrate that in schema itself.
(require '[schema.core :as s])
(require '[schema-tools.core :as st])
(require '[schema-tools.coerce :as stc])
(s/defschema PageRequest
{:attributes (st/default [s/Str] ["enum"])})
;; enforce the defaults
(stc/coerce {:attributes nil} PageRequest stc/default-coercion-matcher)
; {:attributes ["enum"]}
@ikitommi Many thanks, I'm implementing now. Note for future folks, the help namespace is new, so if you're on stable (1.1.10) it won't show up.