-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Allow 'type' to be array, based on JSON Schema Draft4(partial solution for 'oneOf' problem). #624
Comments
parent issue #579 |
Tackling PR: #741 |
Couldn't help but notice this wasn't tackled in #741? The spec still states:
Are there plans to support this in 3.x? |
No, you can use |
sure, that's a tooling concern though, no? This is more about the specification definition than an existing implementation. |
Good point. For this particular issue then, is it more of a "won't implement" rather than an proposal? There was a rather large discussion in #333 (and I assume #1026 will go that way too) that hinted supporting something like this could make life difficult for tools that consume Open API. My impression from that is that this wouldn't be rolled into the spec anytime soon... |
It's my belief that it won't be implemented right now, but there is a process to roll up open proposals into possible next-spec changes. |
Spin off from #333, see this comment.
JSON Schema Draft4 supports arrays as values of
type
properties:So you can write:
And it validates both string and array of strings.
It can be easily implemented in static-typed languages. Let's imagine following OpenAPI spec:
Based on it you can generate base class
Data
and two childsDataString
andDataArray
.An appropriate class can be easily chosen based on data themselves based on type of actual JSON value.
So functional it's very similar to how
discriminator
works.I think such step towards JSON Schema resolves a lot of
oneOf
controversial without introducing too many problems for underlining tools.The text was updated successfully, but these errors were encountered: