This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-03
Channels
- # aleph (7)
- # announcements (6)
- # babashka (34)
- # beginners (5)
- # calva (1)
- # cider (3)
- # clerk (11)
- # clj-http (1)
- # clj-kondo (35)
- # clojars (6)
- # clojure (114)
- # clojure-australia (1)
- # clojure-brasil (2)
- # clojure-europe (73)
- # clojure-hamburg (3)
- # clojure-nl (1)
- # clojure-norway (27)
- # clojure-uk (4)
- # events (3)
- # graalvm (13)
- # gratitude (4)
- # helix (17)
- # hoplon (1)
- # hyperfiddle (65)
- # instaparse (4)
- # jobs-discuss (6)
- # lsp (2)
- # meander (2)
- # rdf (4)
- # re-frame (51)
- # reitit (28)
- # releases (1)
- # sci (20)
- # shadow-cljs (9)
- # tools-deps (4)
- # xtdb (44)
Trying to use it but get an error in Swagger UI:
Unable to render this definition
The provided definition does not specify a valid version field.
Please indicate a valid Swagger or OpenAPI version field. Supported version fields are swagger: "2.0" and those that match openapi: 3.0.n (for example, openapi: 3.0.0).
Seems like the UI wasn't updated to be compatible with OpenAPI 3.1. But maybe I'm doing something wrong - any clues?Ah, I had to manually specify the latest metosin/ring-swagger-ui
in my deps. Otherwise, the latest alpha of metosin/reitit-swagger-ui
is pulling an older version.
Some other feedback: :example
is ignored in parameters (documented here: https://swagger.io/docs/specification/adding-examples/). But at least I can provide :json-schema/example
.
Also, query parameter description doesn't show up.
However, the whole map schema description does show up for every parameter.
So if I use :query [:map [:x {:description "hi"} :string]]
, that "hi"
will not be shown.
But if I use :query [:map {:description "hi"} [:x :string] [:y :int]]
, that "hi"
will show up for both x
and y
.
Ah, found the issue for it: https://github.com/metosin/reitit/issues/612
thanks, sorry about the ring-swagger-ui version mixup. need to sort that up before release
the best doc for examples is this test currently: https://github.com/metosin/reitit/blob/master/test/cljc/reitit/openapi_test.clj#L436
if I want to clean up (e.g. trim + lower-case a field) some wire input that's spec'd with malli before it reaches the handler, where should that go? custom interceptor? decode/string
?
• :decode/string
for query, path, header and form params
• :decode/json
form JSON

yeah, I went through that thread three times but couldn't make it work for application/transit+json
and have no idea how to debug it
now, one can set extra transformers via custom config, but that’s a lot of boilerplate and there is no proper guide how to do that.
if you are in a hurry, add a custom interceptor (before request-coercion-interceptor) for this.
what I tried was
(def coercion
(rcm/create (update-in rcm/default-options
[:transformers :body :formats]
assoc
"application/edn" rcm/string-transformer-provider
"application/transit+json" rcm/string-transformer-provider)))
should that + decode/string be enough?e.g. here: https://github.com/metosin/reitit/blob/master/doc/coercion/malli_coercion.md#configuring-coercion
it didn’t work though. I’ll have time today to both try it again, write some docs and create a gh issue
issue is here: https://github.com/metosin/reitit/issues/620
ok, got it to work in ring_coercion_test:
["/body" {:summary "decoding for non-json"
:coercion (reitit.coercion.malli/create {:transformers
{:body
{:formats
{"application/edn"
reitit.coercion.malli/string-transformer-provider}}}})
:post {:parameters {:body [:map
[:x
{:decode/string clojure.string/lower-case}
string?]]}
:responses {200 {:body [:map [:x string?]]}}
:handler (fn [req]
{:status 200
:body (-> req :parameters :body)})}}]
must be doing something else wrong in the main project repo. thanks for the help! later today will have a PR with the tip