title: How to remove the response body of an operation in Springfox Swagger?
body: <p>I'm working in a REST service made with spring-boot, which to this day is documented using springfox-swagger2:2.7.0 (implementation first). The last operation I've added looks like this:</p>
  
  <pre><code>@ApiOperation(value = "whatever")
    @ApiResponses({
      @ApiResponse(code = HttpURLConnection.HTTP_NO_CONTENT, message = "Returns empty content when succeeds"),
      @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "You can't do that.")
    })
  @CrossOrigin
  @PreAuthorize("hasAuthority('USER_ACCESS')")
  @RequestMapping(value = "/foo", method = POST, consumes = APPLICATION_JSON_VALUE)
  @ResponseStatus(HttpStatus.NO_CONTENT)
  public ResponseEntity postFoo(
    @RequestBody
    FooRequestBody requestBody) {
  
    if (someMethodReturnsTrue()) {
      return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
    } else {
      return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
    }
  }
  </code></pre>
  
  <p>Now, the problem is that no matter what, the generated Swagger definition ends up looking like this:</p>
  
  <pre><code>"responses": {
    "204": {
      "description": "Returns empty content when succeeds",
      "schema": {
        "$ref": "#/definitions/ResponseEntity"
      }
    },
    "403": {
      "description": "You can't do that."
    }
  }
  </code></pre>
  
  <p>Provided that this operation returns nothing, I understand that the "204" response should have no <code>schema</code> field (like the other one).</p>
  
  <p>I've tried specifying <code>response = Void.class</code> in the <code>@ApiParam</code> annotation (as suggested in other threads) with no joy (since it is the default value it is indistinguishable from not specifying it).</p>
  
  <p>I've also tried setting <code>genericModelSubstitutes(ResponseEntity.class)</code> in my <code>Docket</code> bean and that did nothing.</p>
  
  <p>I know that instead of returning <code>ResponseEntity</code> I could return <code>void</code> and throw and exception in case <code>someMethodReturnsTrue()</code> returns indeed <code>false</code>. An <code>@ExceptionHandler</code> method could then turn that exception into a 403 status code.</p>
  
  <p>I think this is overkill, I think I shouldn't be changing my implementation to fix my documentation. That's why I ask, is there any way to tell Springfox to ignore the return value of that specific method and treat it as if it returned <code>void</code>?</p>
  
  <p>Thanks.</p>