package com.example.zxweb.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author 赵恒
 * @date 2023/5/12
 * Swagger 配置页面
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket docketYichang() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo())
                .groupName("demo1")
                .select().apis(RequestHandlerSelectors.basePackage("com.example"))
                .build();
    }

    @Bean
    public Docket docketWuhan() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo())
                .groupName("文档1")
                .select().apis(RequestHandlerSelectors.basePackage("com.example"))
                .build();
    }

    // String title, String description, String version, String termsOfServiceUrl, Contact contact, String license, String licenseUrl, Collection<VendorExtension>
    @Bean
    public ApiInfo getApiInfo() {
        // Contact(String name, String url, String email)
        Contact contact = new Contact("hxlc", "https://www.baotao.com", "1111@163.com");
        return new ApiInfo("zx-java", "接口模型", "1.0", "url", contact, "Apache Foundation", null, new ArrayList<>());
    }
}
