package shop.alien.lawyer.config;

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;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger配置类
 *
 * @author ssk
 * @version 1.0
 * @date 2024/12/4 9:17
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /**
     * controller扫描
     *
     * @return controller扫描
     */
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("爱丽恩2.0Api服务")
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * Api标题信息
     *
     * @return api标题Api标题信息
     */
    public ApiInfo apiInfo() {
        Contact contact = new Contact("爱丽恩", "https://www.alien.shop", "");
        return new ApiInfoBuilder()
                .title("爱丽恩2.0Api服务")
                .description("爱丽恩2.0Api服务")
                .license("爱丽恩")
                .contact(contact)
                .termsOfServiceUrl("https://www.alien.shop")
                .version("1.0.0")
                .build();
    }
}
