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

Support oneOf when describing requestBody #193

Open
bobics opened this issue Nov 12, 2018 · 7 comments
Open

Support oneOf when describing requestBody #193

bobics opened this issue Nov 12, 2018 · 7 comments

Comments

@bobics
Copy link

bobics commented Nov 12, 2018

Is your feature request related to a problem? Please describe.
I'd like a way to describe two request bodies to the same API path, but with somewhat different bodies. For example, say I have a /user path, and want to be able to create a regular user and a manager user, where the manager user has multiple other fields that need to be set.

Describe the solution you'd like
The OpenAPI 3.0 spec supports oneOf for requestBody -> content -> application/json -> schema, per the docs:

      requestBody:
        description: A JSON object containing pet information
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/Cat'
                - $ref: '#/components/schemas/Dog'
                - $ref: '#/components/schemas/Hamster'

https://swagger.io/docs/specification/describing-request-body/

Right now if you use oneOf here, it doesn't show any of the requestBodies.

Describe alternatives you've considered
I'm also tried using multiple requestBody examples per this other ticket I created, but unfortunately that isn't supported either.

@MikeRalphson MikeRalphson self-assigned this Nov 13, 2018
@Flo354
Copy link

Flo354 commented Jan 11, 2019

Hi there,

Any ETA for this feature?

Thanks :)

@MikeRalphson
Copy link
Contributor

No ETA at the moment, I'm afraid. Pull requests would be very welcome!

@Flo354
Copy link

Flo354 commented Jan 11, 2019

Thanks for your answer, I'll look if I can do something

@MikeRalphson MikeRalphson pinned this issue Jan 14, 2019
@sirinn
Copy link

sirinn commented Apr 22, 2020

Hi, do we have any ETA on this ? If not can I get a summary of what needs to be changed with possible code pointers where to look for inspiration ? I guess this could be similar to the request response examples right ? Any pitfalls ?

@MikeRalphson
Copy link
Contributor

Generally unless an issue is tied to a milestone with a date on it, then there is no ETA. I'll try and take a look at what's (not) going on and either fix or write it up for someone else.

MikeRalphson added a commit that referenced this issue May 15, 2020
@manuelhartl
Copy link

is there still progress on this topic? having no proper support on oneOf/allOf renders the openapi-generator unusable for many use cases

@MikeRalphson
Copy link
Contributor

@manuelhartl do you mean openapi-generator? That's a completely separate project.

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

No branches or pull requests

5 participants