widdershins icon indicating copy to clipboard operation
widdershins copied to clipboard

Support `oneOf` when describing `requestBody`

Open bobics opened this issue 5 years ago • 7 comments

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.

bobics avatar Nov 12 '18 23:11 bobics

Hi there,

Any ETA for this feature?

Thanks :)

Flo354 avatar Jan 11 '19 14:01 Flo354

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

MikeRalphson avatar Jan 11 '19 14:01 MikeRalphson

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

Flo354 avatar Jan 11 '19 14:01 Flo354

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 ?

sirinn avatar Apr 22 '20 09:04 sirinn

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 avatar Apr 22 '20 10:04 MikeRalphson

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

manuelhartl avatar Mar 11 '21 15:03 manuelhartl

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

MikeRalphson avatar Mar 11 '21 15:03 MikeRalphson