Skip to content
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

oneOf behaviour clarification #3477

Closed
SAPRD2 opened this issue Dec 21, 2023 · 4 comments
Closed

oneOf behaviour clarification #3477

SAPRD2 opened this issue Dec 21, 2023 · 4 comments

Comments

@SAPRD2
Copy link

SAPRD2 commented Dec 21, 2023

We were going through the oneOf explanations given in the swagger website.
image
As mentioned above, in the case of oneOf, the input

{
  "bark": true,
  "breed": "Dingo" 
}

is a valid input. But, looking closely at the given spec, we see that it is a valid input for both the schemas, since neither the required, nor the discriminator keyword is defined in any schema (Cat or Dog), which means that the above input is a valid input for both the schemas.
Can you please clarify if the above input is a valid input for the given schema or not ?
Thanks.

@iglosiggio
Copy link

iglosiggio commented Dec 21, 2023

(my interpretation of the spec) It should not validate: oneOf requires that validation succeeds against exactly one schema. Also, adding a discriminator should not change this behavior.

@SAPRD2
Copy link
Author

SAPRD2 commented Dec 22, 2023

So based on that, should the documentation be changed to say that it is NOT a valid input for the given oneOf example ?

@LasneF
Copy link
Member

LasneF commented Dec 22, 2023

you are right , but notice that the website you refer belong to SmartBear , and not OAS specficiation. That said you can ping them for sure . The OAS spec could have this kind of sample, but this would also be the duty of JsonSchema
if you want to have more around that you can have a look there
https://json-schema.org/blog/posts/applicability-json-schema-fundamentals-part-1#putting-everything-together-avoiding-oneof-pitfalls

Try to grab SmartBear Folks to fix it will be indeed good for the community as they are an important actor over there

@handrews
Copy link
Member

Since there is no problem with the specification here (which is what this repo is for), I'm going to close it. But I join the other folks in encouraging you to file this issue with SmartBear/Swagger! Thank you for asking about it :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants