diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml
index 0846e47c3..228c99b2f 100644
--- a/yudao-dependencies/pom.xml
+++ b/yudao-dependencies/pom.xml
@@ -233,6 +233,11 @@
knife4j-openapi3-spring-boot-starter
${knife4j.version}
+
+ com.github.xiaoymin
+ knife4j-gateway-spring-boot-starter
+ ${knife4j.version}
+
diff --git a/yudao-gateway/pom.xml b/yudao-gateway/pom.xml
index cef02f3d9..e605770e2 100644
--- a/yudao-gateway/pom.xml
+++ b/yudao-gateway/pom.xml
@@ -58,8 +58,7 @@
com.github.xiaoymin
- knife4j-spring-boot-starter
- 3.0.3
+ knife4j-gateway-spring-boot-starter
@@ -85,7 +84,6 @@
cn.iocoder.cloud
yudao-spring-boot-starter-monitor
-
diff --git a/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/swagger/SwaggerHandler.java b/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/swagger/SwaggerHandler.java
deleted file mode 100644
index 7cae3c810..000000000
--- a/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/swagger/SwaggerHandler.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.iocoder.yudao.gateway.swagger;
-
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import reactor.core.publisher.Mono;
-import springfox.documentation.swagger.web.*;
-
-import javax.annotation.Resource;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * Swagger Controller
- *
- * @author zxliu
- * @date 2022-10-25 11:24
- */
-@RestController
-@RequestMapping("/swagger-resources")
-public class SwaggerHandler {
-
- @Resource
- private SwaggerResourcesProvider swaggerResources;
-
- @SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") // 只有 @Autowired 可以实现可选注入
- @Autowired(required = false)
- private SecurityConfiguration securityConfiguration;
- @SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") // 只有 @Autowired 可以实现可选注入
- @Autowired(required = false)
- private UiConfiguration uiConfiguration;
-
- @GetMapping("")
- public Mono>> swaggerResources() {
- return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));
- }
-
- @GetMapping("/configuration/security")
- public Mono> securityConfiguration() {
- return Mono.just(new ResponseEntity<>(Optional.ofNullable(securityConfiguration)
- .orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK));
- }
-
- @GetMapping("/configuration/ui")
- public Mono> uiConfiguration() {
- return Mono.just(new ResponseEntity<>(Optional.ofNullable(uiConfiguration)
- .orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK));
- }
-
-}
diff --git a/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/swagger/SwaggerProvider.java b/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/swagger/SwaggerResourceHandlerFunction.java
similarity index 66%
rename from yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/swagger/SwaggerProvider.java
rename to yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/swagger/SwaggerResourceHandlerFunction.java
index 03aee0fbc..b88a50e2b 100644
--- a/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/swagger/SwaggerProvider.java
+++ b/yudao-gateway/src/main/java/cn/iocoder/yudao/gateway/swagger/SwaggerResourceHandlerFunction.java
@@ -2,45 +2,49 @@ package cn.iocoder.yudao.gateway.swagger;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.config.GatewayProperties;
import org.springframework.cloud.gateway.handler.predicate.PredicateDefinition;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.cloud.gateway.support.NameUtils;
-import org.springframework.context.annotation.Primary;
+import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
-import springfox.documentation.swagger.web.SwaggerResource;
-import springfox.documentation.swagger.web.SwaggerResourcesProvider;
+import org.springframework.web.reactive.function.server.HandlerFunction;
+import org.springframework.web.reactive.function.server.ServerRequest;
+import org.springframework.web.reactive.function.server.ServerResponse;
+import reactor.core.publisher.Mono;
import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
/**
- * Swagger 资源的 Provider 实现类
+ * 获得 Swagger 资源的 {@link HandlerFunction} 实现类
*
* @author zxliu
* @since 2022-10-25 11:23
*/
-@Component
-@Primary
+@RequiredArgsConstructor
@Slf4j
-public class SwaggerProvider implements SwaggerResourcesProvider {
+public class SwaggerResourceHandlerFunction implements HandlerFunction {
- @Resource
- private GatewayProperties gatewayProperties;
+ private final GatewayProperties gatewayProperties;
+
+ @Override
+ public Mono handle(ServerRequest request) {
+ return ServerResponse.ok()
+ .contentType(MediaType.APPLICATION_JSON)
+ .bodyValue(getSwaggerResourceList());
+ }
/**
* 获得 SwaggerResource 列表
*
* @return SwaggerResource 列表
*/
- @Override
- public List get() {
+ public List