//package cn.superdesk.uniorder.config;
//
//import java.util.Arrays;
//import java.util.List;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Import;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.context.request.async.DeferredResult;
//
//import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
//import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.builders.ResponseMessageBuilder;
//import springfox.documentation.schema.ModelRef;
//import springfox.documentation.service.ApiInfo;
//import springfox.documentation.service.Contact;
//import springfox.documentation.service.ResponseMessage;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
//
//
///**
// * Swagger2 配置
// *
// * @author linjinyu
// * @email linjinyu@avic-s.com
// * @date 2020-08-20 19:16:08
// */
//@Configuration
//@EnableSwagger2
//@Import(BeanValidatorPluginsConfiguration.class)
//public class Swagger2 {
//
//    @Bean
//    public Docket createRestApi(@Value("${swagger.enable:false}") boolean enable) {
//
//        String basePackage = "cn.superdesk.uniorder.controller";
//
//        System.setProperty("controller.base-package", basePackage);
//
//        return new Docket(DocumentationType.SWAGGER_2)
//                .apiInfo(apiInfo())
//                .enable(enable)
//                .groupName("superdesk-uniorder")
//                .genericModelSubstitutes(DeferredResult.class)
//                .useDefaultResponseMessages(false)
//                .globalResponseMessage(RequestMethod.GET, customerResponseMessage())
//                .forCodeGeneration(true)
//                .select()
//                .apis(RequestHandlerSelectors.basePackage(basePackage))
//                .paths(PathSelectors.any())
//                .build();
//    }
//
//    private ApiInfo apiInfo() {
//        return new ApiInfoBuilder()
//                .title("Superdesk UniOrder Services APIs")
//                .description("Superdesk UniOrder Services Readme")
//                .termsOfServiceUrl("https://www.superdesk.cn/superdesk-uniorder")
//                .contact(new Contact("linjinyu", "", "linjinyu@avic-s.com"))
//                .version("1.0")
//                .build();
//    }
//
//    /**
//     * 自定义返回信息
//     *
//     * @return
//     */
//    private List<ResponseMessage> customerResponseMessage() {
//        return Arrays.asList(
//                new ResponseMessageBuilder()//500
//                        .code(9999)
//                        .message("系统繁忙")
//                        .responseModel(new ModelRef("Error"))
//                        .build(),
//                new ResponseMessageBuilder()//401
//                        .code(401)
//                        .message("未授权访问")
//                        .build());
//    }
//
//
//}
