Commit 3e06a537ac7cc8588d785921986737736f172a39

Authored by 谭毅彬
1 parent 16b64262

调整swagger默认参数配置

Signed-off-by: TanYibin <5491541@qq.com>
huaheng-wms-core/src/main/java/org/jeecg/utils/config/Swagger3Config.java
@@ -51,12 +51,16 @@ public class Swagger3Config implements WebMvcConfigurer { @@ -51,12 +51,16 @@ public class Swagger3Config implements WebMvcConfigurer {
51 */ 51 */
52 @Bean(value = "defaultApi2") 52 @Bean(value = "defaultApi2")
53 public Docket defaultApi2() { 53 public Docket defaultApi2() {
54 - return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()  
55 - // 此包路径下的类,才生成接口文档  
56 - .apis(RequestHandlerSelectors.basePackage("org.jeecg.modules.wms.api"))  
57 - // 加了ApiOperation注解的类,才生成接口文档  
58 - .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class)).apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))  
59 - .paths(PathSelectors.any()).build().securitySchemes(Collections.singletonList(securityScheme())).securityContexts(securityContexts()); 54 + return new Docket(DocumentationType.SWAGGER_2)
  55 + .apiInfo(apiInfo())
  56 + .select()
  57 + .apis(RequestHandlerSelectors.basePackage("org.jeecg.modules.wms.api"))// 此包路径下的类,才生成接口文档
  58 + .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))// 加了ApiOperation注解的类,才生成接口文档
  59 + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
  60 + .paths(PathSelectors.any())
  61 + .build()
  62 + .securitySchemes(Collections.singletonList(securityScheme()))
  63 + .securityContexts(securityContexts());
60 // .globalOperationParameters(setHeaderToken()); 64 // .globalOperationParameters(setHeaderToken());
61 } 65 }
62 66
@@ -68,7 +72,7 @@ public class Swagger3Config implements WebMvcConfigurer { @@ -68,7 +72,7 @@ public class Swagger3Config implements WebMvcConfigurer {
68 */ 72 */
69 @Bean 73 @Bean
70 SecurityScheme securityScheme() { 74 SecurityScheme securityScheme() {
71 - return new ApiKey(CommonConstant.X_ACCESS_TOKEN, CommonConstant.X_ACCESS_TOKEN, "header"); 75 + return new ApiKey("TOKEN", "token", "header");
72 } 76 }
73 77
74 /** 78 /**
@@ -88,7 +92,7 @@ public class Swagger3Config implements WebMvcConfigurer { @@ -88,7 +92,7 @@ public class Swagger3Config implements WebMvcConfigurer {
88 .title("华恒仓储管理系统API接口文档") 92 .title("华恒仓储管理系统API接口文档")
89 // 版本号 93 // 版本号
90 .version("1.0") 94 .version("1.0")
91 -// .termsOfServiceUrl("NO terms of service") 95 +// .termsOfServiceUrl("NO terms of service")
92 // 描述 96 // 描述
93 .description("后台API接口").license("The Apache License, Version 2.0").licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html").build(); 97 .description("后台API接口").license("The Apache License, Version 2.0").licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html").build();
94 } 98 }
@@ -97,7 +101,7 @@ public class Swagger3Config implements WebMvcConfigurer { @@ -97,7 +101,7 @@ public class Swagger3Config implements WebMvcConfigurer {
97 AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); 101 AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
98 AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; 102 AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
99 authorizationScopes[0] = authorizationScope; 103 authorizationScopes[0] = authorizationScope;
100 - return Collections.singletonList(new SecurityReference(CommonConstant.X_ACCESS_TOKEN, authorizationScopes)); 104 + return Collections.singletonList(new SecurityReference("TOKEN", authorizationScopes));
101 } 105 }
102 106
103 } 107 }