This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-23
Channels
- # adventofcode (21)
- # announcements (4)
- # babashka (35)
- # beginners (36)
- # calva (76)
- # cider (16)
- # clj-kondo (24)
- # clj-on-windows (12)
- # clojure (70)
- # clojure-europe (7)
- # clojure-nl (13)
- # clojure-spec (3)
- # clojure-uk (3)
- # clojurescript (34)
- # conjure (11)
- # cursive (22)
- # datomic (30)
- # deps-new (2)
- # emacs (36)
- # fulcro (28)
- # gratitude (4)
- # honeysql (16)
- # hugsql (8)
- # introduce-yourself (5)
- # jobs (1)
- # malli (4)
- # missionary (6)
- # off-topic (129)
- # other-languages (34)
- # polylith (3)
- # reagent (9)
- # reitit (27)
- # releases (13)
- # remote-jobs (1)
- # reveal (1)
- # shadow-cljs (2)
- # tools-build (3)
- # tools-deps (18)
- # web-security (7)
- # xtdb (4)
A question related to how reitit generates swagger HTML page and data. Is it possible to specify a schema for the request body and to support "application/edn" as a parameter content type ?
I tried different thing but I couldn't make it work
When I enter a EDN piece of data in the swagger UI, the "Execute" button seems to be blocked
It seems that having a schema per media type is a feature of Swagger v3.0 From https://swagger.io/docs/specification/describing-request-body/
OpenAPI 3.0 uses the requestBody keyword to distinguish the payload from parameters (such as query string). The requestBody is more flexible in that it lets you consume different media types, such as JSON, XML, form data, plain text, and others, and use different schemas for different media types
Unfortunately reitit supports only swagger 2 for now and there is already a Github issue for adding Swagger 3 support https://github.com/metosin/reitit/issues/8
I guess I was able to answer my question by myself
Thank you for your attention 😜
But I still have a question: what if If want only to support "application/edn" content type? Is it supported by reitit?
@viebel yes, currently, you’ll need to mount a custom :muuntaja
into route data, with just application/edn
supported. Can be at top-level or just for some routes. The Swagger UI had a bug related to malforned JSON (e.g. EDN) in the body-form, I think it’s fixed in the latest versions.
you can also just annotate any an endpoint with :swagger {:produces #{"application/edn"}}
to hint that it only takes edn. doesn’t effect the actual decoding, just an ui-hint.
Full support for OpenAPI 3.0 is… on the backlog, not even a big thing, just not implemented.
@ikitommi This is what I did but when I press the "Execute button" nothing happens.
I use [metosin/ring-swagger-ui "4.0.0"]
. Does it contain the Swagger UI bug fix?
Nothing in the browser console. Have you seen that?
Indeed you have seen that https://github.com/swagger-api/swagger-ui/issues/6295#issuecomment-782812903
sorry, don’t have time to investigate, heading to holidays. hopefully you’ll find a resolution for that.
The link I shared is a comment of yours saying that you experienced the bug.
I found it funny
No need to investigate.
Enjoy your holiday
When I add a :
between the keys and the values (making it a valid JSON), the Execute button works
We’ll (at Metosin) will re-visit our open source strategy, many libs haven’t got the attention they would deserve in 2021, reitit included. This was not planned, people have just been too busy with client projects and COVID puts a strain on the work/life balance. Will most likely deprecate some old libs and focus on the relevant ones (reitit included). Also, lot’s of new ideas, but need to find time to work on those. PRs always most welcome 🙂
What Metosin brings is already awesome. But the more you consume it, the more the appetite grows.