Swagger3如果没有设置分组,则所有的API接口全在一个default分组中,如下所示:
但是如果功能模块和接口数量逐渐增多时,就会显得有些凌乱,不方便查找和使用,这时可提供的解决方法就是对API接口进行分组,配置多个分组只需要配置多个docket,并通过Swagger实例Docket的groupName()
方法定义各个分组名
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
@Configuration
public class Swagger3Config {
@Bean
public Docket createRestApi