From 45f83dff430077ffecf71f4f5c70a3d91e18a15e Mon Sep 17 00:00:00 2001 From: JEECG <445654970@qq.com> Date: Wed, 13 Aug 2025 16:45:40 +0800 Subject: [PATCH] # Conflicts: # jeecg-boot/jeecg-boot-base-core/pom.xml --- jeecg-boot/jeecg-boot-base-core/pom.xml | 13 ++++---- .../java/org/jeecg/config/Swagger3Config.java | 31 ++++++------------- jeecg-boot/pom.xml | 2 +- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/jeecg-boot/jeecg-boot-base-core/pom.xml b/jeecg-boot/jeecg-boot-base-core/pom.xml index ee2a4b80a..2c2f946d3 100644 --- a/jeecg-boot/jeecg-boot-base-core/pom.xml +++ b/jeecg-boot/jeecg-boot-base-core/pom.xml @@ -212,12 +212,13 @@ spring-security-cas - - com.github.xingfudeshi + + + com.github.xiaoymin knife4j-openapi3-ui @@ -227,8 +228,8 @@ org.springdoc springdoc-openapi-starter-webmvc-ui 2.7.0 - --> - + + diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/Swagger3Config.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/Swagger3Config.java index 1878b5827..0700b463a 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/Swagger3Config.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/Swagger3Config.java @@ -10,11 +10,12 @@ import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.constant.CommonConstant; -import org.springdoc.core.customizers.GlobalOpenApiCustomizer; +import org.springdoc.core.customizers.OperationCustomizer; import org.springdoc.core.filters.GlobalOpenApiMethodFilter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -61,29 +62,17 @@ public class Swagger3Config implements WebMvcConfigurer { } @Bean - public GlobalOpenApiCustomizer globalOpenApiCustomizer() { - return openApi -> { - // 全局添加鉴权参数 - if (openApi.getPaths() != null) { - openApi.getPaths().forEach((path, pathItem) -> { - //log.info("path: {}", path); - // 检查当前路径是否在排除列表中 - boolean isExcluded = excludedPaths.stream().anyMatch( - excludedPath -> excludedPath.equals(path) || (excludedPath.endsWith("**") && path.startsWith(excludedPath.substring(0, excludedPath.length() - 2))) - ); - - if (!isExcluded) { - //log.info(" 接口添加默认X_ACCESS_TOKEN: {}", path); - // 接口添加鉴权参数 - pathItem.readOperations().forEach(operation -> - operation.addSecurityItem(new SecurityRequirement().addList(CommonConstant.X_ACCESS_TOKEN)) - ); - } - }); + public OperationCustomizer operationCustomizer() { + return (operation, handlerMethod) -> { + String path = handlerMethod.getBeanType().getAnnotation(RequestMapping.class).value()[0]; + if (!excludedPaths.contains(path)) { + operation.addSecurityItem(new SecurityRequirement().addList(CommonConstant.X_ACCESS_TOKEN)); } + return operation; }; } - + + @Bean public OpenAPI customOpenAPI() { return new OpenAPI() diff --git a/jeecg-boot/pom.xml b/jeecg-boot/pom.xml index cbad553eb..0e534abcc 100644 --- a/jeecg-boot/pom.xml +++ b/jeecg-boot/pom.xml @@ -43,7 +43,7 @@ 5.2.6 1.6.0 0.17.0 - 4.6.0 + 4.5.0 42.2.25 11.2.0.3