Forum Discussion
- HKosovaSmartBear Alumni (Retired)
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'
- NixolOccasional 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.- HKosovaSmartBear 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:
Related Content
- 5 years ago
- 5 years ago
- 4 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 8 days ago