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.

2.8.0: can't disable default http StatusCodes at method level

See original GitHub issue

For 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: image

… are you also seeing this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dilipkrishcommented, Sep 15, 2018

@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

1reaction
Krokogatorcommented, Sep 11, 2018

Add @ResponseStatus(HttpStatus.CREATED) This will replace default 200 code

Read more comments on GitHub >

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

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