Home > OS >  Remove Controller Name in Swagger UI
Remove Controller Name in Swagger UI

Time:03-27

Is there any way to hide the controller name in the swagger-ui.

enter image description here

My class is like this. I do not want my controller name on the ui.

@Api(tags = {"group"})
public class MyControllerName {}

I did check some existing answers. for ex: How to remove controller list from Swagger UI did not help at all.

CodePudding user response:

Create Docket bean and assign to it custom ApiInfo object, in this way:

@Bean
public Docket api() {                
    return new Docket(DocumentationType.SWAGGER_2)          
      .select()
      .apis(RequestHandlerSelectors.basePackage("com.example.controller"))
      .paths(PathSelectors.ant("/foos/*"))
      .build()
      .apiInfo(apiInfo());
}

private ApiInfo apiInfo() {
    return new ApiInfo(
      "My REST API", 
      "Some custom description of API.", 
      "API TOS", 
      "Terms of service", 
      new Contact("John Doe", "www.example.com", "[email protected]"), 
      "License of API", "API license URL", Collections.emptyList());
}

CodePudding user response:

This sould be good feature request to springfox team. If you need to customize the swagger-UI you should be doing it on your own.

Maybe the below steps are useful for someone.

  1. Go to https://github.com/swagger-api/swagger-ui
  2. Download the latest code
  3. customize whatever you want to customize
  4. package either as a web jar or as resources in your application
  5. create resource handler mapping if required

Refer - https://github.com/springfox/springfox/issues/1108

  • Related