Allow for multiple response schemas for each response code
See original GitHub issueExample
responses:
200:
description: An array of events
schema:
type: array
items:
$ref: '#/definitions/Event'
200:
description: |
An array of flattened events. This is the response
object when singleEvents is True.
schema:
type: array
items:
$ref: '#/definitions/EventFlat'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
Issue Analytics
- State:
- Created 9 years ago
- Reactions:162
- Comments:81 (25 by maintainers)
Top Results From Across the Web
Swagger; specify two responses with same code based on ...
OAS2 does not support multiple response schemas per status code. You can only have a single schema, for example, a free-form object (...
Read more >Swagger: Specify Two Responses with the Same ... - Baeldung
Learn how to write an API specification that returns two different objects for the same response code using Java and Swagger.
Read more >Describing Responses - Swagger
Under responses , each response definition starts with a status code, such as 200 or 404. ... This is useful if multiple media...
Read more >Swagger responses - Multiple response codes with t...
Hi! Is it possible to have multiple codes use the same schema without duplicating the schema-reference? I.e.: responses: '202': description: ...
Read more >Multiple messages for the same http status code not displayed.
What you can do is have a single 400 response code description describing the multiple options..
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I doubt we’ll support that any time soon. One of the leading principles we have behind Swagger is API determinism. By saying that a single response may return various object types, that pretty much breaks that principle.
Also would vote for adding multiple responses with the same code. The best example would be any
400 (Bad request)
error which can be caused by many reasons. Take in example validation errors: missing fields, extra fields passed or simply wrong data provided - these all are different errors grouped under the same status code where exact error is returned in response playload, which may vary for each situation. This is still considered as deterministic behaviour as it is uniquely defined in response playload.