-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support s/keys
key-groups in openapi spec
#619
Comments
spec-tools isn't sophisticated enough to know how to convert that into json-schema. |
Hi again. I may be able to help on this after all - here is some initial (somewhat encouraging) info: The whole thing seemed impossible when I first looked at it (several months back), but I've had two significant realisations since...
In any case, as I said I'll try to have a stub at this of not this week, then the following after it... 👍 |
Ok, so here is an attempt at discovering key-groups: (defn- parse-required-with [f x]
(if (seq? x) ;; key-group
(let [k (condp = (first x)
'or :oneOf ;; or :anyOf ?
'and :allOf
(throw
(IllegalArgumentException. "unsupported key-group expression")))]
{k (mapv (partial parse-required-with f) (next x))})
{:required [(f x)]}))
(def parse-req (partial parse-required-with impl/qualified-name))
(def parse-req-un (partial parse-required-with name))
(parse-req-un '(or :foo (and :bar :baz))) ;; => {:oneOf [{:required ["foo"]} {:allOf [{:required ["bar"]} {:required ["baz"]}]}]} You can get a list of those maps by simply mapping over the req(-un) vectors, and wrapping everything in top level |
Hello,
I was under the impression that specs like the one below, didn't show correctly on the swagger-v2 schema because it doesn't support this kind of
one-of
semantics. I believe that openapi-v3 does support it, but unfortunately, the same thing happens - all the keys show up as required (i.e. with a red asterisk).Any thoughts?
[EDIT]:
Sorry, I should have mentioned that I am using the recently released
0.7.0-alpha1
.The text was updated successfully, but these errors were encountered: