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

package com.codvision.workflow.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("workflowSwaggerConfig")
@EnableSwagger2
@EnableSwaggerBootstrapUI
public class SwaggerConfig {

    @Bean
    public Docket workflowApiConfig() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(webApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.codvision.workflow"))
                .build().groupName("工作流模块");
    }

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