I'm using Swagger annotations and SpringFox to produce a Swagger spec for my REST API (being built with Sprint Boot). I'm annotating each method with the @ApiResponse
codes that will be returned. For example:
@DeleteMapping("/{pipelineName}")
@ApiOperation(value = "Delete a specific pipeline")
@ApiResponses({
@ApiResponse(code = 204, message = "Pipeline has been deleted"),
@ApiResponse(code = 404, message = "Pipeline does not exist")
})
public void deletePipeline(@PathVariable("pipelineName") @ApiParam(value = "Name of pipeline", required = true) String name){
...
}
However, something (I assume SpringFox) is adding a 200 response code to every API call regardless of whether it's defined or not. I'm aware that I can remove this by adding a @ResponseStatus
annotation to each method, but a) that seems like unneccessary duplication of the @ApiResponse definitions and b) some methods could return one of multiple 2xx codes.
Is there a way or removing the 200 code that is added by default?