This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-09
Channels
- # announcements (47)
- # asami (43)
- # babashka (37)
- # beginners (119)
- # bitcoin (1)
- # calva (5)
- # circleci (5)
- # clj-kondo (36)
- # cljs-dev (5)
- # cljsrn (1)
- # clojure (92)
- # clojure-australia (2)
- # clojure-bay-area (2)
- # clojure-europe (121)
- # clojure-italy (7)
- # clojure-japan (1)
- # clojure-nl (4)
- # clojure-serbia (2)
- # clojure-uk (66)
- # clojuredesign-podcast (2)
- # clojurescript (19)
- # conjure (2)
- # cursive (13)
- # data-oriented-programming (2)
- # datomic (53)
- # defnpodcast (7)
- # depstar (33)
- # events (1)
- # fulcro (21)
- # graalvm (47)
- # jobs (1)
- # kaocha (1)
- # lambdaisland (1)
- # luminus (2)
- # malli (14)
- # membrane (16)
- # off-topic (45)
- # polylith (2)
- # re-frame (11)
- # reitit (7)
- # releases (1)
- # reveal (15)
- # rewrite-clj (123)
- # shadow-cljs (7)
- # sql (21)
- # startup-in-a-month (3)
- # tools-deps (25)
- # vim (2)
Hello! When using reitit + malli (coercion) + Swagger integration, is there a way to tell Swagger what is the type of a certain schema attribute? I used to have models with optional attributes defined like [:map [:attribute {:optional true} string?]]
and that showed as expected on the Swagger ui (i.e. attribute
is not required and has type string). But I had to change the attribute definition to [:map [:attribute [:or nil? string?]]]
and now the attribute type is not showed as string anymore on Swagger ui. Is there a way to say what type should appear on the ui, something like [:map [:attribute {:type string} [:or nil? string?]]]
?
This is an interesting question, not sure of how smart the swagger generator can be.
Not sure if this was answered yet.
(json-schema/transform [:or {:json-schema/type "string"} int? string?] )
;; => {:anyOf [{:type "integer", :format "int64"} {:type "string"}],
;; :type "string"}
Though in this case [:maybe string?]
would be more precise than :or
. But not sure if it works any better with SwaggerUI. :or
generates anyOf
json-schema, :maybe
generates oneOf
.Any properties from schema options with json-schema
namespaces are lifted to the resulting json-schema, and override the automatic properties.
@U061V0GG2 What is the practical difference between oneOf
and anyOf
?
In this case, probably nothing
This is an interesting question, not sure of how smart the swagger generator can be.
Not sure if this was answered yet.
(json-schema/transform [:or {:json-schema/type "string"} int? string?] )
;; => {:anyOf [{:type "integer", :format "int64"} {:type "string"}],
;; :type "string"}
Though in this case [:maybe string?]
would be more precise than :or
. But not sure if it works any better with SwaggerUI. :or
generates anyOf
json-schema, :maybe
generates oneOf
.