question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support `oneOf` when describing `requestBody`

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:11
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Flo354commented, Jan 11, 2019

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

1reaction
MikeRalphsoncommented, Apr 22, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Describing Request Body - Swagger
OpenAPI 3.0 supports anyOf and oneOf , so you can specify alternate schemas for the request body: requestBody: description: A JSON object containing...
Read more >
Request Body OneOf references not resolving correctly
When referencing Request Bodies in a OneOf the preview image shows "any" instead of the actual reference. If OneOf is required for the...
Read more >
How to annotate to require individual elements of requestBody ...
There should not be more than 1 Request Body to a given endpoint! · Request Body is mostly a JSON object. Thus to...
Read more >
Working With Composite Schemas In Integration Server Using ...
Ensure that the request body matches with one of the schemas in the service. If the request body contains any variations, the validation ......
Read more >
OpenAPI Specification
Throughout the specification description fields are noted as supporting CommonMark ... Only one of the security requirement objects need to be satisfied to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found