2.8.0: can't disable default http StatusCodes at method level
See original GitHub issueFor instance, with class level responses as a default for the included methods:
...
@RequestMapping(value = "/api/carriers")
@Api(tags = { "carriers" }, value = "API root for carrier related functions.")
@io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid status value", response = void.class),
@ApiResponse(code = 500, message = "Internal server error", response = void.class) })
...
and then additionally in the method:
...
@RequestMapping(method = RequestMethod.POST)
@ApiOperation(value = "Creates a new carrier", notes = "", response = void.class)
@io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 201, message = "successful operation", response = void.class),
@ApiResponse(code = 422, message = "validation failure", response = void.class),
@ApiResponse(code = 409, message = "uniqueness violation", response = void.class) })
public ResponseEntity<Void> postCarrier(
...
…also config is disabling default codes:
...
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).securityContexts(securityContext()).useDefaultResponseMessages(false)
.select().apis(RequestHandlerSelectors.any()).paths(PathSelectors.any()).build();
}
...
…we should be seeing 201, 400, 409, 422 and 500, but we always also see the 200 there, for some reason:
… are you also seeing this?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
java - Swagger 2 Issue - Spring Boot - Stack Overflow
Searching about I tried to change versions to 2.8.0, 2.7.0, 3.0.0... also returns error. The application is an apirest with task list activities ......
Read more >Spring Boot RESTful API Documentation with Swagger 2
Swagger 2 is a very popular tool set for documenting RESTful interfaces developed with Spring Boot. In this post I show you how...
Read more >Azure Application Insights for ASP.NET Core applications
This article describes how to enable and configure Application Insights for an ASP.NET Core application. Application Insights can collect ...
Read more >HTTP response status codes - MDN Web Docs - Mozilla
The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request...
Read more >Apache Tomcat 8 (8.5.84) - Changelog
Remove unnecessary code that exposed the asyncTimeout to components ... 66184: Ensure that JULI root loggers have a default level of INFO ....
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
@Krokogator thanks for jumping in. While that works, someone in the forum mentioned that it isnt accurate to use that solution.
this seems like a good feature to have. Thanks for reporting @jtviegas
Add
@ResponseStatus(HttpStatus.CREATED)
This will replace default 200 code