/*
 * Copyright (c) 2023 codvision.com All Rights Reserved.
 */

package com.codvision.base.config;

import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger配置
 *
 * @author lingee
 * @date 2023/8/4
 */
@Configuration("baseSwaggerConfig")
@EnableSwagger2
@EnableSwaggerBootstrapUI
public class SwaggerConfig {

    @Bean
    public Docket baseApiConfig() {
        return new Docket(DocumentationType.SWAGGER_2)
                // 创建接口文档的具体信息
                .apiInfo(webApiInfo())
                // 创建选择器，控制哪些接口被加入文档
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.codvision.base"))
                // 指定@ApiOperation标注的接口被加入文档
                //.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .build().groupName("基础能力中心");
    }

    /**
     * 创建接口文档的具体信息，会显示在接口文档页面中
     *
     * @return ApiInfo
     */
    private ApiInfo webApiInfo() {
        return new ApiInfoBuilder()
                // 文档标题
                .title("基础能力中心接口管理")
                // 文档描述
                .description("基础能力中心接口文档")
                // 版本
                .version("1.0")
                // 版权
                .license("Codvision")
                // 版权地址
                .licenseUrl("http://www.codvision.com")
                .build();
    }
}
