Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response 200 always added to POST / DELETE #908

hazsetata opened this issue Aug 12, 2015 · 2 comments


Copy link

@hazsetata hazsetata commented Aug 12, 2015


I'm new to Springfox / Swagger, and can't figure out how to remove default 200 response code from POST / DELETE methods. I'm using Springfox 2.1.2:

    compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.1.2
    compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.1.2'

And the following config (in a spring-boot project):

public class SpringfoxConfiguration {
    public Docket apiDocumentation() {
        return new Docket(DocumentationType.SWAGGER_2)

For the following endpoint definition:

    @RequestMapping(value = "/roles/create", method = RequestMethod.POST)
            value = "Creates a new role",
            notes = "Can be called only by users with 'auth management' rights."
    @ApiResponses(value = {
            @ApiResponse(code = 201, message = "Role created successfully"),
            @ApiResponse(code = 400, message = "Role name already in use")
    public void createRole(@Valid @RequestBody RoleCreateDTO roleDTO) {

I get the following JSON snippet in the generated Swagger file:

/api/v1/auth/roles/create: {
  post: {
      tags: ["authentication-resource"],
      summary: "Creates a new role",
      description: "Can be called only by users with 'auth management' rights.",
      operationId: "createRoleUsingPOST",
      consumes: ["application/json"],
      produces: ["*/*"],
      parameters: [
              in: "body",
              name: "roleDTO",
              description: "roleDTO",
              required: true,
              schema: {$ref: "#/definitions/RoleCreateDTO"}
      responses: {
              200: {description: "OK"},
              201: {description: "Role created successfully"},
              400: {description: "Role name already in use"}

Where does response "200" come from, and how could I remove it (I tried 'response = Void.class' in @ApiOperation, but that didn't help either)?

Any help would be great, thanks, br:



This comment has been minimized.

Copy link

@dilipkrish dilipkrish commented Aug 12, 2015

Adding the annotation


to your method should fix it.

@dilipkrish dilipkrish added the question label Aug 12, 2015
@dilipkrish dilipkrish added this to the 2.2.0 milestone Aug 12, 2015
@dilipkrish dilipkrish closed this Aug 15, 2015

This comment has been minimized.

Copy link

@HuntMark HuntMark commented May 11, 2017

When I use ResponseEntity as return type
return new ResponseEntity<>(null, headers, HttpStatus.CREATED);
@ResponseStatus adds duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.