Forum Discussion
OpenAPI only allows one POST/GET/etc. operation per path, but you can define multiple possible request bodies by using oneOf:
paths:
/something:
post:
operationId: createSomething
requestBody:
required: true
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Body1'
- $ref: '#/components/schemas/Body2'
- Nixol4 years agoOccasional Contributor
Thanks HKosova for your explanation.
Could you also assist to answer the following followup questions:
1. can each of the requests have a different tag? eg. Body1 has "TagA" and body2 has "TagB"
2. can each of the requests have a corresponding response? e.g. if Body1 is used, then the response will be Response1, if Body2 is used then the response will be Response2.- HKosova4 years agoSmartBear Alumni (Retired)
1. No.
2. No. You can use oneOf to define the possible response schemas, but OpenAPI doesn't support request/response correlation.
Here's a related feature request you can track:
- Nixol4 years agoOccasional Contributor
Is there any plans to include the previously mentioned scenarios in future releases? It will be great if this can be done. Thanks
Related Content
- 5 years ago
- 5 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 8 days ago