metosin / spec-tools

Clojure(Script) tools for clojure.spec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

s/keys + clojure.core/or -> swagger returns or args as required

nikolavojicic opened this issue · comments

Using clojure.core/or inside :req of s/keys, when transformed to openapi / swagger / json-schema, shows all its args as required, which is not correct:

(s/def ::foo string?)
(s/def ::bar string?)
(s/def ::baz number?)

(openapi/transform (s/keys :req-un [::foo (or ::bar ::baz)]))
;=>
{:type "object",
 :properties
 {"foo" {:type "string"},
  "bar" {:type "string"},
  "baz" {:type "number", :format "double"}},
 :required ["foo" "bar" "baz"]}