This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-16
Channels
- # announcements (2)
- # asami (124)
- # babashka (30)
- # babashka-sci-dev (73)
- # beginners (40)
- # biff (1)
- # calva (39)
- # clj-kondo (54)
- # clj-otel (1)
- # cljdoc (59)
- # cljs-dev (8)
- # clojars (2)
- # clojure (96)
- # clojure-austin (16)
- # clojure-boston (6)
- # clojure-europe (51)
- # clojure-nl (1)
- # clojure-norway (1)
- # clojure-russia (60)
- # clojure-uk (4)
- # clojurescript (34)
- # community-development (6)
- # cursive (2)
- # datahike (10)
- # datascript (18)
- # emacs (109)
- # etaoin (1)
- # events (3)
- # figwheel-main (41)
- # fulcro (13)
- # helix (4)
- # introduce-yourself (5)
- # jobs (1)
- # leiningen (5)
- # lsp (8)
- # malli (6)
- # meander (7)
- # nrepl (6)
- # off-topic (60)
- # pathom (29)
- # polylith (8)
- # re-frame (5)
- # reitit (1)
- # releases (1)
- # remote-jobs (1)
- # rewrite-clj (33)
- # sci (3)
- # shadow-cljs (3)
- # xtdb (82)
Hi there. I was wondering if anyone might have hints or pointers for understanding the interaction of reitit, malli, and custom registries? I think this might be related to what @weavejester was asking about, above. I think my question boils down to, if I build a coercer with a provided registry, like:
(def schemas
(merge
(m/default-schemas)
{::id string?
::timestamp inst?
::thing
[:map {:closed true}
[:id ::id]
[:other ::id]
[:timestamp inst?]]}))
(def registry-coercion
(reitit.coercion.malli/create
(assoc reitit.coercion.malli/default-options
:options {:registry (mr/registry schemas)})))
... what's the right way to provide schema information to an operation? Things like the following don't seem to work -- swagger-ui invariably reports 'Could not resolve reference.' --
(def thing
(m/schema ::thing {:registry schemas}))
(def app
(ring/ring-handler
(ring/router
[["/swagger.json"
{:get {:no-doc true
:swagger {:info {:title "my-api"}}
:handler (swagger/create-swagger-handler)}}]
["" {:coercion registry-coercion}
["/echo"
{:post {:summary "Echo a coerced complex type."
:parameters {:body thing}
:swagger {:responses {400 {:schema {:type "string"}}}}
:responses {200 {:body thing}
500 {:description "fail"}}
:handler (fn [{{xs :body} :parameters}]
{:status 200
:body xs})}}]]]
{:exception pretty/exception
:data {:coercion registry-coercion
... etc
Pointers into code are most welcome. Just wondering if I've already gone so far off course that my error is evident. Cheers! (oh, by the way, if I just use def'ed m/schema instances, it all works fine)