question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add support of multiple @ApiResponse with the same code

See original GitHub issue

ApiResponse 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:open
  • Created 8 years ago
  • Reactions:3
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
floatincommented, Dec 22, 2015

Need it too.

1reaction
angelo-chancommented, May 21, 2018

+1

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found