title: Springfox Swagger adding response status 200 to POST and PUT
body: <p>I am using springfox-swagger2 version 2.6.1, and it is inserting HTTP 200 response messages for PUT and POST operations automatically, despite my attempts to configure it not to do so (I do not use response status 200 for POST or PUT, but 201 and 204, respectively); see below screenshot:</p>
  
  <p><a href="https://i.stack.imgur.com/E9VKB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/E9VKB.png" alt="enter image description here"></a></p>
  
  <p>I have seen answers to similar questions where the authors suggest adding a <code>@ResponseStatus</code> annotation to your controller to "fix" it, but this becomes inflexible and goes against Spring's own documentation regarding the use of <code>ResponseEntity</code> vs <code>@ResponseStatus</code> for rest APIs. Examples:</p>
  
  <p><a href="https://stackoverflow.com/questions/37405244/how-to-change-the-response-status-code-for-successful-operation-in-swagger">How to change the response status code for successful operation in Swagger?</a></p>
  
  <p>and</p>
  
  <p><a href="https://github.com/springfox/springfox/issues/908" rel="noreferrer">https://github.com/springfox/springfox/issues/908</a></p>
  
  <p>Is there any other way to force Springfox Swagger not to add this 200 OK status code?</p>
  
  <p>My Docket configuration:</p>
  
  <pre><code>@Bean
  public Docket api() {
      return new Docket(DocumentationType.SWAGGER_2)
              .useDefaultResponseMessages(false)
              .select().
                      apis(RequestHandlerSelectors.any()).
                      paths(paths()).
                      build()
              .pathMapping("/")
              .apiInfo(apiInfo())
              .genericModelSubstitutes(ResponseEntity.class)
              .alternateTypeRules(newRule(
                      typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
                      typeResolver.resolve(WildcardType.class)
              ));
  </code></pre>
  
  <p>...and the actual API endpoint declaration:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST, produces = "application/json")
  @ApiOperation(value = "Create a new enrolment", code = 201)
  @ApiResponses(value = {
          @ApiResponse(code = 201, message = "New enrolment created",
                  responseHeaders = @ResponseHeader(name = "Location", description = "The resulting URI of the newly-created enrolment", response = String.class))})
  @ResponseStatus(HttpStatus.CREATED)
  public ResponseEntity&lt;Void&gt; saveNewEnrolment(@ApiParam(value = "Enrolment to save", required = true) @RequestBody final Enrolment enrolment) {
      // implementation code removed; "location" header is created and returned
      return ResponseEntity.created(location).build();
  }
  </code></pre>