package com.icloud.server.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
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;

/**
 * @Author : yang
 * @Date : 2019/4/1 11:16 AM
 * @Version : 1.2.1 implements WebMvcConfigurer
 */
//@EnableWebMvc
@Configuration
@EnableSwagger2
public class Swagger2  {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.icloud.server"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("API文档")
                .description("朝阳")
                .termsOfServiceUrl("http://www.occloud.com/-")
                .version("1.2.1")
                .build();
    }
//



//
//
//    @Bean
//    public Docket getDocket(){
//        ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder();
//        //指定封面信息
//        apiInfoBuilder.title("ocloud 后端接口说明")
//                .description("此文档详细说明了后端接口规范")
//                .version("v 2.0.1")
//                .contact( new Contact("eason","www.occloud.com","11267800@qq.com"))
//                .build();
//
//        ApiInfo apiInfo = apiInfoBuilder.build();
//
//        //指定生成策略
//        Docket docket = new Docket(DocumentationType.SWAGGER_2)//指定文档路径
//                .apiInfo(apiInfo)
//                .select()
//                .apis(RequestHandlerSelectors.basePackage("com.occloud.server"))
//                .paths(PathSelectors.any())
//                .build();
//
//        return docket;
//    }

//
//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/**").addResourceLocations(
//                "classpath:/static/");
//        registry.addResourceHandler("swagger-ui.html").addResourceLocations(
//                "classpath:/META-INF/resources/");
//        registry.addResourceHandler("/webjars/**").addResourceLocations(
//                "classpath:/META-INF/resources/webjars/");
//        WebMvcConfigurer.super.addResourceHandlers(registry);
//    }






}
