|
@@ -1,7 +1,10 @@
|
|
|
package com.gis.common.config;
|
|
|
|
|
|
+import com.gis.common.constant.ConfigConstant;
|
|
|
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import springfox.documentation.builders.ApiInfoBuilder;
|
|
@@ -30,16 +33,21 @@ import java.util.List;
|
|
|
*
|
|
|
* 2.9.2 不需要字启动类配置注解
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Configuration
|
|
|
@EnableSwagger2
|
|
|
@EnableKnife4j
|
|
|
public class Swagger2 {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ConfigConstant configConstant;
|
|
|
+
|
|
|
@Bean
|
|
|
public Docket createRestApi() {
|
|
|
return new Docket(DocumentationType.SWAGGER_2)
|
|
|
.apiInfo(apiInfo())
|
|
|
.select()
|
|
|
- .apis(RequestHandlerSelectors.basePackage("com.gis.web.controller"))
|
|
|
+ .apis(RequestHandlerSelectors.basePackage(configConstant.swaggerPackage))
|
|
|
.paths(PathSelectors.any())
|
|
|
.build()
|
|
|
//添加登录认证,可以使用token
|
|
@@ -50,16 +58,15 @@ public class Swagger2 {
|
|
|
|
|
|
private ApiInfo apiInfo() {
|
|
|
return new ApiInfoBuilder()
|
|
|
- .title("VR720 房车宝")
|
|
|
- .description("VR720 房车宝 Api接口文档")
|
|
|
- .version("1.0")
|
|
|
+ .title(configConstant.swaggerTitle)
|
|
|
+ .description(configConstant.swaggerDescription)
|
|
|
+ .version(configConstant.swaggerVersion)
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
private List<ApiKey> securitySchemes() {
|
|
|
//设置请求头信息
|
|
|
List<ApiKey> result = new ArrayList<>();
|
|
|
-// ApiKey apiKey = new ApiKey("Authorization", "Authorization", "header");
|
|
|
ApiKey apiKey = new ApiKey("Authorization", "token", "header");
|
|
|
result.add(apiKey);
|
|
|
return result;
|