-
-
Notifications
You must be signed in to change notification settings - Fork 268
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
[BUG] oneOf and similar tools unexpectedly require 2 or more items #492
[BUG] oneOf and similar tools unexpectedly require 2 or more items #492
Comments
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request. Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue. |
@Z5eyhS0uubejR0SVmX2O this part is guilty here https://github.com/asyncapi/asyncapi/blob/master/versions/2.0.0/schema.json#L402. I checked the spec https://github.com/asyncapi/asyncapi/blob/master/versions/2.0.0/asyncapi.md and do not see anything specific saying that AsyncAPI Schema is restricting I'm of course curious why you need @fmvilas is it a bug or is there a valid reason to have |
I think it's a bug. There will be cases where the |
@derberg I'm using it where I basically want inheritance. Using a $ref completely overrides the definition, but sometimes I want to simply extend a base schema with additional properties:
The Because I sometimes do this, I actually overuse the I mix and match these things regularly:
|
@derberg @fmvilas |
@Z5eyhS0uubejR0SVmX2O thanks for describing the use case for me 🙇🏼 would you like to open up a PR to fix those bugs? It would have to get to yes, we need to duplicate atm 😞 but we are at least aware 😄 |
@derberg PRs created, but I'm concerned the testing failures manifesting aren't something I directly caused with my commits. Linting broken on node repo: Test broken specifically on |
@Z5eyhS0uubejR0SVmX2O that was fast! thanks. I provided instructions on how to fix CI for asyncapi-node. For the failing test on windows in asyncapi repo, just do not worry, we will merge what you have and fix it with a followup PR |
@fmvilas from my perspective I see those PRs as correct, so once @Z5eyhS0uubejR0SVmX2O updates one of them we can merge imho, objections? |
@derberg I would like to begin using the tool and it's a lot easier to do that if I don't have to go in and revise my existing JSON schemas :-) |
@derberg Nope! Let's keep moving forward with bug fixes :) |
* Change minItems of oneOf and anyOf to 1 asyncapi/spec#492 * Add explicit lack of linter to fix PR Action
@Z5eyhS0uubejR0SVmX2O your fixes are already available in all asyncapi tools |
Thank @derberg, I pulled the latest Docker image yesterday evening and started playing! |
Describe the bug
The
oneOf
schema attribute requires 2 or more items, but should work with a single value in the array.To Reproduce
Steps to reproduce the behavior:
oneOf
oneOf should NOT have fewer than 2 items
Expected behavior
By JSON Schema specification, there is no restriction that there be 2 or more items in a
oneOf
or siblings. In practice, tools including this JSON Schema Validator and Swagger Editor will accept a single definition foroneOf
.JSON schema example :
JSON value example:
OpenAPI 3 example:
Note: I'm not necessarily trying to say that "just because OpenAPI does it, you should", but I think the implication is that those groups of tools share an interpretation of the JSON schema spec which
asyncapi
does not. Sure would be nice if there was alignment though :-).Sample document
Additional context
I might just work around this, but it's an adoption hurdle that I have to go in and modify my existing base of JSON schemas to adopt
asyncapi
. Otherwise, super psyched to have this tool added to the arsenal next to OpenAPI 3!The text was updated successfully, but these errors were encountered: