Commit f0095a2c312653a6b7afe9f3a142a5142453537f

Authored by YunaiV
1 parent 33d09469

完善 YudaoSwaggerAutoConfiguration 注释

yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/ServiceErrorCodeRange.java
... ... @@ -29,6 +29,10 @@ package cn.iocoder.yudao.framework.common.exception.enums;
29 29 */
30 30 public class ServiceErrorCodeRange {
31 31  
32   - // 模块 system 错误码区间 [1-000-001-000 ~ 1-000-002-000]
  32 + // 模块 infra 错误码区间 [1-001-000-000 ~ 1-002-000-000)
  33 + // 模块 system 错误码区间 [1-002-000-000 ~ 1-003-000-000)
  34 + // 模块 member 错误码区间 [1-004-000-000 ~ 1-005-000-000)
  35 + // 模块 pay 错误码区间 [1-007-000-000 ~ 1-008-000-000)
  36 + // 模块 bpm 错误码区间 [1-009-000-000 ~ 1-010-000-000)
33 37  
34 38 }
... ...
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java
... ... @@ -3,7 +3,6 @@ package cn.iocoder.yudao.framework.swagger.config;
3 3 import cn.iocoder.yudao.framework.swagger.core.SpringFoxHandlerProviderBeanPostProcessor;
4 4 import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
5 5 import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
6   -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
7 6 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
8 7 import org.springframework.boot.context.properties.EnableConfigurationProperties;
9 8 import org.springframework.context.annotation.Bean;
... ... @@ -45,27 +44,22 @@ public class YudaoSwaggerAutoConfiguration {
45 44 }
46 45  
47 46 @Bean
48   - @ConditionalOnMissingBean
49   - public SwaggerProperties swaggerProperties() {
50   - return new SwaggerProperties();
51   - }
52   -
53   - @Bean
54   - public Docket createRestApi() {
55   - SwaggerProperties properties = swaggerProperties();
  47 + public Docket createRestApi(SwaggerProperties properties) {
56 48 // 创建 Docket 对象
57 49 return new Docket(DocumentationType.SWAGGER_2)
58   - // 用来创建该 API 的基本信息,展示在文档的页面中(自定义展示的信息)
  50 + // ① 用来创建该 API 的基本信息,展示在文档的页面中(自定义展示的信息)
59 51 .apiInfo(apiInfo(properties))
60   - // 设置扫描指定 package 包下的
  52 + // ② 设置扫描指定 package 包下的
61 53 .select()
62 54 .apis(basePackage(properties.getBasePackage()))
63 55 // .apis(basePackage("cn.iocoder.yudao.module.system")) // 可用于 swagger 无法展示时使用
64 56 .paths(PathSelectors.any())
65 57 .build()
  58 + // ③ 安全上下文(认证)
66 59 .securitySchemes(securitySchemes())
67   - .globalRequestParameters(globalRequestParameters())
68   - .securityContexts(securityContexts());
  60 + .securityContexts(securityContexts())
  61 + // ④ 全局参数(多租户 header)
  62 + .globalRequestParameters(globalRequestParameters());
69 63 }
70 64  
71 65 // ========== apiInfo ==========
... ... @@ -100,6 +94,7 @@ public class YudaoSwaggerAutoConfiguration {
100 94 private static List<SecurityContext> securityContexts() {
101 95 return Collections.singletonList(SecurityContext.builder()
102 96 .securityReferences(securityReferences())
  97 + // 通过 PathSelectors.regex("^(?!auth).*$"),排除包含 "auth" 的接口不需要使用securitySchemes
103 98 .forPaths(PathSelectors.regex("^(?!auth).*$"))
104 99 .build());
105 100 }
... ...