Remove Basic Error Controller In SpringFox SwaggerUI

Is there a way i can remove the "basic-error-controller" from springfox swagger-ui?

Picture:

enter image description here


Solution 1:

You can restrict the request handler selector to scan only the package of your project:

    return new Docket( DocumentationType.SWAGGER_2)
        .select()
        .apis( RequestHandlerSelectors.basePackage( "your package" ) )
        ...

Solution 2:

I think, the most elegant solution is to include only @RestController controllers into swagger, only thing to bear in mind, is to annotate all the REST controllers with that annotation:

new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
            .paths(PathSelectors.any())
            .build();

As BasicErrorController is annotated with @Controller only, swagger would avoid BasicErrorController in definition file. Of course you can use your custom annotation instead of @RestController to mark your REST controllers as controllers eligible by swagger.