How to let swagger control group display

In Swagger, you normally divide the API into groups and each group will have a Docket.

But many times, you do not want someone or some environment to see all groups . you want to control each group showing or not. This looks like a difficult task after some search. But in fact swagger already has this feature in Docket.

@Bean
public Docket myDocket() {
return new Docket(DocumentationType.SWAGGER_2).groupName("MYAPI").apiInfo(...).select().paths(....)
.build().useDefaultResponseMessages(false).forCodeGeneration(true).enable(true);
}

So enable(boolean) is part to control enable method for the group. You can use your configuration or role logic to control this flag value to control the group here.

 

Advertisements