add support of multiple @ApiResponse with the same code
See original GitHub issueApiResponse with the same code is not supported. It would be useful when one response code is used for multiple errors with custom structure: ErrorMessage{httpStatus, errorCode, developerMessage, userMessage}
@Api(value = "/pet")
@RequestMapping(value = "/pet", method = RequestMethod.GET)
public interface PetResource {
@ApiOperation(value = "Find pet by ID")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "SUCCESS", response = Pet.class),
@ApiResponse(code = 500, message = "errorCode=SOME_CODE_1", response = ErrorMessage.class),
@ApiResponse(code = 500, message = "errorCode=SOME_CODE_2", response = ErrorMessage.class)
@ApiResponse(code = 500, message = "errorCode=SOME_CODE_3", response = ErrorMessage.class)
})
@RequestMapping(value = "/{petId}", method = RequestMethod.GET)
Pet getPetById(@PathVariable("petId") Long petId);
}
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:10 (1 by maintainers)
Top Results From Across the Web
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 >How to render duplicated @ApiResponse code with swagger ...
I'll add and say that the reason for it is that it just doesn't make sense to have multiple messages for a response...
Read more >Cannot have multiple ApiResponse attributes with same ...
I just recently discovered that having multiple ApiResponse attributes with the same status code but different descriptions breaks openapi ...
Read more >Multiple messages for the same http status code not displayed.
xml and the main service class that defines my resources that has annotations. Thanks,.. MessageApplication.java.
Read more >Response - Web APIs - MDN Web Docs - Mozilla
The status message corresponding to the status code. (e.g., OK for 200 ). Response.trailers ... Creates a new response with a different URL....
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
Need it too.
+1