package com.openapi.config;

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.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**   
* SwaggerConfig.java
* 项目名称:
* 包:
* 类名称:   SwaggerConfig.java
* 类描述:   构建restful api接口文档
* 创建人:
* 创建时间:  2017 下午4:23:45   
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig
{
	
	/**
	* 描述api的基本信息
	* 基本信息会展现在文档页面中
	* @return [api的基本信息]
	*/
    ApiInfo apiInfo()
    {
        return new ApiInfoBuilder().title("hgj-CWeb").description("提供给用户端的接口").termsOfServiceUrl("").version("1.0.0")
            .contact(new Contact("", "", "")).build();
    }

    @Bean
    public Docket customImplementation()
    {
        return new Docket(DocumentationType.SWAGGER_2).select()
            .apis(RequestHandlerSelectors.basePackage("com"))
            .build().directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
            .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class).apiInfo(apiInfo());
    }

}
