Commit 34d39279 authored by 张永's avatar 张永

1

parent d31428f3
package com.egolm.admin.config; package com.egolm.admin.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;
import com.egolm.common.DateUtil;
import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
...@@ -9,27 +13,36 @@ import springfox.documentation.builders.RequestHandlerSelectors; ...@@ -9,27 +13,36 @@ import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo; import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration @Configuration
@EnableSwagger2
public class SwaggerConfig { public class SwaggerConfig {
@Value("${server.servlet.context-path}")
private String contextPath;
@Value("${maven.build.timestamp}")
private String mavenBuildTime;
@Bean @Bean
public Docket createRestApi() { public Docket ProductApi() {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo()) .genericModelSubstitutes(DeferredResult.class)
.useDefaultResponseMessages(false)
.forCodeGeneration(false)
.pathMapping("/")
.select() .select()
.apis(RequestHandlerSelectors.basePackage("com.egolm.admin")) .build()
.paths(PathSelectors.any()) .apiInfo(productApiInfo());
.build();
} }
private ApiInfo apiInfo() { private ApiInfo productApiInfo() {
String releaseTime = DateUtil.formatTimeEight(mavenBuildTime.replace("T"," ").replace("Z", ""));
return new ApiInfoBuilder() return new ApiInfoBuilder()
.title("B2B运营平台服务") .title("B2B后台在线接口服务-------"+contextPath+"---发布时间:-"+releaseTime)
.description("在线文档")
.termsOfServiceUrl("NO terms of service") .termsOfServiceUrl("NO terms of service")
.version("1.0") .version("1.0")
.build(); .build();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment