This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-22
Channels
- # announcements (1)
- # babashka (94)
- # beginners (11)
- # biff (9)
- # calva (21)
- # clj-kondo (14)
- # clojure (12)
- # clojure-europe (56)
- # clojure-nl (1)
- # clojure-norway (41)
- # clojure-uk (4)
- # clojurescript (4)
- # core-logic (2)
- # gratitude (12)
- # honeysql (1)
- # hoplon (3)
- # hugsql (7)
- # introduce-yourself (2)
- # jobs-discuss (23)
- # leiningen (3)
- # malli (11)
- # off-topic (1)
- # pedestal (11)
- # reagent (3)
- # squint (8)
- # vim (9)
- # xtdb (3)
Hello! First of all, thank you for malli. It's beautiful.
So, my question is as follows
How properly show in swagger-ui structure like a :multi
or :or
For example
[:multi {:dispatch :type}
[:sized [:map [:type keyword?] [:size int?]]]
[:human [:map [:type keyword?] [:name string?] [:address [:map [:country keyword?]]]]]]
(defmethod accept :multi [_ _ children _] (let [cs (mapv last children)] (assoc (first cs) :x-anyOf cs)))
As I understand it, here we take only the first part and the rest is not visible in swagger-ui.
i.e. in the model in swagger-ui I will see only :sized
I'd appreciate any ideas
or maybe is it ok for swagger?)
UPD someone is using swagger-ui ? and has used anyOf ?I don't think :multi
can be fully represented in swagger since the dispatch function can be any function. In our project we therefore introduced a custom :multi-map
which specializes for a :type
-key dispatch style multi schema whose children all have to be :map
or :multi-map
. This allows for representing it in less expressive formats (TypeScript declarations in our case - I don't know if swagger / open-api has support for this).
As for :or
I would assume that swagger should support this :thinking_face:
OpenAPI supports discriminator, which should help here if the :dispatch
uses a key, see https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/
maybe we should support also functions when doing transformations to xyz from malli? so, instead of:
[:multi {:openapi {:type ....}}]
we could have:
[:multi {:openapi (fn [schema options] ...transform here...)}]
… that would allow easy in-place transformations.Specal-casing keyword-based dispatch is a nice idea 👍
oh https://github.com/swagger-api/swagger-ui/issues/2438 that's my problem.