How to hide endpoints from Swagger documentation with Springfox

One more way is to use @ApiOperation(hidden = true) This can be used at controller/handler level method. E.g.

@RestController
public HomeController{
@ApiOperation(value = "<Your Message>", hidden = true)
    public String getMessage(@RequestParam(value = "msg") final String msg){
        return msg;
    }
}

You have added the @ApiIgnore annotation on an interface. It looks like, this annotation doesn't work when added on an interface. (I really don't understand why @Api works on an interface and @ApiIgnore don't. 😕)

Add the annotation directly to your controller class. This should solve your problem.

The hidden property on the @Api annotation doesn't work currently. (See this GitHub issue.)


For OpenAPI3 and SpringBoot:
I used @Hidden annotation on a method of a controller.
It seems to work both at method level and controller level.

@Hidden annotation was imported from using:

import io.swagger.v3.oas.annotations;

The scenario where we want to hide only a particular method(s) from the class. For swagger.v3 there is an annotation with name Hidden in io.swagger.core.v3:swagger-annotations:2.0.10 jar. Methods to be hidden can be annotated with Hidden annotation as shown below. The below method shows the method with DELETE operation which needs to be hidden from the swagger documentation.

@DELETE
@Hidden
public void deleteList(int id) {
//code goes here.
}