|
|
@@ -2,23 +2,48 @@ package com.hp.user.service.config; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import cn.nyhlw.doc2swagger.springswagger2.EnableSwagger2; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
|
|
|
import cn.nyhlw.doc2swagger.core.config.RestDocConfig; |
|
|
|
import cn.nyhlw.doc2swagger.springswagger2.EnableSwagger2; |
|
|
|
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; |
|
|
|
|
|
|
|
@Configuration |
|
|
|
@EnableSwagger2 |
|
|
|
public class SwaggerConfig { |
|
|
|
public static final String VERSION = "1.0.0"; |
|
|
|
public static final String SWAGGER_SCAN_BASE_PACKAGE = "com.hp.user.service.controller"; |
|
|
|
@Bean |
|
|
|
RestDocConfig _swaggerConfig() |
|
|
|
{ |
|
|
|
return RestDocConfig.builder() |
|
|
|
.apiTitle("rest doc user") |
|
|
|
.apiDescription("用户信息系统") |
|
|
|
.apiVersion("1.0.0") |
|
|
|
.packages(Arrays.asList("com.hp.user.service.controller")) |
|
|
|
.build(); |
|
|
|
public Docket createRestApi() { |
|
|
|
return new Docket(DocumentationType.SWAGGER_2) |
|
|
|
.apiInfo(apiInfo()) |
|
|
|
.select() |
|
|
|
.apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE)) |
|
|
|
.paths(PathSelectors.any()) |
|
|
|
.build(); |
|
|
|
} |
|
|
|
|
|
|
|
private ApiInfo apiInfo() { |
|
|
|
return new ApiInfoBuilder() |
|
|
|
.title("rest doc user") |
|
|
|
.description("用户信息系统") |
|
|
|
// .termsOfServiceUrl("http://www.cnblogs.com/congc/") |
|
|
|
.version(VERSION) |
|
|
|
.build(); |
|
|
|
} |
|
|
|
// RestDocConfig _swaggerConfig() |
|
|
|
// { |
|
|
|
// return RestDocConfig.builder() |
|
|
|
// .apiTitle("rest doc user") |
|
|
|
// .apiDescription("用户信息系统") |
|
|
|
// .apiVersion("1.0.0") |
|
|
|
// .packages(Arrays.asList("com.hp.user.service.controller")) |
|
|
|
// .build(); |
|
|
|
// } |
|
|
|
} |