[Feature Request] Multiple response with the same status code
See original GitHub issueI’m submitting a…
[ ] Regression
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
Swagger only allows one response per status code, but sometimes we have more than one response body.
Expected behavior
We can work around this in the decorator by:
- Changing the status field type from
number
tonumber | string
- Checking if the
status
already exists - If it exists, we add a space to the response code
Minimal reproduction of the problem
@ApiForbiddenResponse({ type: UnauthorizedTokenException })
@ApiForbiddenResponse({ type: InsufficientRolesException })
What is the motivation / use case for changing the behavior?
I have more than one error response with different Dto
classes using the same status code.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:31
- Comments:21 (7 by maintainers)
Top Results From Across the Web
Swagger; specify two responses with same code based on ...
OpenAPI 3.x. In OAS3 you can use oneOf to define multiple possible request bodies or response bodies for the same operation: openapi: ...
Read more >Parsing Multiple responses inside the response xml. - Help
I have a job with multiple invoices listed under the job. I send a request and it shows all the multiple invoices and...
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 >Describing Responses - Swagger
HTTP Status Codes · responses: · 200: · description: OK · 400: · description: Bad request. User ID must be an integer and...
Read more >Define multiple responses for each route - Mockoon
For each route, multiple responses can be defined (status, body, and headers) and triggered using a set of rules. There is always at...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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
Any updates?
Could you share your
UserOrderInfoDto
implementation? Make sure it is aclass
and not aninterface
.EDIT: Ok, I’m sorry I didn’t realize this earlier. Your DTOs should not be wrapped in an array:
Sorry for misleading you. 😞