-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Is oneOf supported inside #/components/schemas section? #1758
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
Comments
|
@MikeRalphson Thanks. Which syntax from my original comment is correct? Both seem to have issues.
|
I think what I'm actually seeing is automatic examples are not populating with oneOf I think thats a known limitation as described here, https://app.swaggerhub.com/help/openapi-3-support Does that make sense? If so I can close this out |
Yes, I think that's the case. BTW both of your examples are technically fine. |
@MikeRalphson Thanks. I wonder why the 2nd one throws an error in the editor then = / |
I suspect the editor might be doing some preprocessing on the yaml, but that's just a guess, and heading off topic for this repo. |
Got it. Thanks for your help @MikeRalphson. Closing this out now. |
I tried to answer this by reading this entire thread at #333, but still not 100% sure.
I know the oneOf keyword can be used inside the requestBody object to reference alternative schemas. However, can someone confirm if oneOf is supported within the #/components/schemas section as well?
For example:
👆 doesn't throw an error in SwaggerHub editor, but it does not populate the interactive documentation (i.e. the ID object is missing in the interactive documentation)
I also tried this, which throws the error "bad indentation of a mapping entry"in the SwaggerHub editor:
I would like to use oneOf inside a schema that is referenced by a request body (as shown above). This creates much less repetition in my case because the two alternatives schemas that could be referenced in the request body with oneOf only differ by one property. One schema needs ID1 and the other needs ID2. There's about 7 other properties that are common across the two schemas, so if I use the oneOf keyword in the requestBody to reference alternative scheams (the way I know it works), then I'm repeating those 7 common properties.
Can someone help confirm if I can instead use oneOf inside #/components/schemas to avoid this repetition?
The text was updated successfully, but these errors were encountered: