From ac9e3f2ca4d2255739f8b60165f5b51b31ccd3e6 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期五, 13 一月 2023 23:04:08 +0800
Subject: [PATCH] update 适配 springdoc 新版本配置方式

---
 ruoyi-framework/src/main/java/com/ruoyi/framework/handler/OpenApiHandler.java |   70 ++++++++++++----------------------
 1 files changed, 25 insertions(+), 45 deletions(-)

diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/handler/OpenApiHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/handler/OpenApiHandler.java
index 608cae5..3bb239e 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/handler/OpenApiHandler.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/handler/OpenApiHandler.java
@@ -9,16 +9,15 @@
 import io.swagger.v3.oas.models.Operation;
 import io.swagger.v3.oas.models.Paths;
 import io.swagger.v3.oas.models.tags.Tag;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springdoc.core.OpenAPIService;
-import org.springdoc.core.PropertyResolverUtils;
-import org.springdoc.core.SecurityService;
-import org.springdoc.core.SpringDocConfigProperties;
 import org.springdoc.core.customizers.OpenApiBuilderCustomizer;
 import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
+import org.springdoc.core.properties.SpringDocConfigProperties;
 import org.springdoc.core.providers.JavadocProvider;
+import org.springdoc.core.service.OpenAPIService;
+import org.springdoc.core.service.SecurityService;
+import org.springdoc.core.utils.PropertyResolverUtils;
 import org.springframework.context.ApplicationContext;
 import org.springframework.core.annotation.AnnotatedElementUtils;
 import org.springframework.util.CollectionUtils;
@@ -34,18 +33,14 @@
  * 鑷畾涔� openapi 澶勭悊鍣�
  * 瀵规簮鐮佸姛鑳借繘琛屼慨鏀� 澧炲己浣跨敤
  */
+@Slf4j
 @SuppressWarnings("all")
 public class OpenApiHandler extends OpenAPIService {
 
     /**
-     * The constant LOGGER.
+     * The Basic error controller.
      */
-    private static final Logger LOGGER = LoggerFactory.getLogger(OpenAPIService.class);
-
-    /**
-     * The Context.
-     */
-    private ApplicationContext context;
+    private static Class<?> basicErrorController;
 
     /**
      * The Security parser.
@@ -60,7 +55,7 @@
     /**
      * The Springdoc tags.
      */
-    private final Map<HandlerMethod, io.swagger.v3.oas.models.tags.Tag> springdocTags = new HashMap<>();
+    private final Map<HandlerMethod, Tag> springdocTags = new HashMap<>();
 
     /**
      * The Open api builder customisers.
@@ -78,24 +73,9 @@
     private final SpringDocConfigProperties springDocConfigProperties;
 
     /**
-     * The Open api.
-     */
-    private OpenAPI openAPI;
-
-    /**
      * The Cached open api map.
      */
     private final Map<String, OpenAPI> cachedOpenAPI = new HashMap<>();
-
-    /**
-     * The Is servers present.
-     */
-    private boolean isServersPresent;
-
-    /**
-     * The Server base url.
-     */
-    private String serverBaseUrl;
 
     /**
      * The Property resolver utils.
@@ -108,24 +88,24 @@
     private final Optional<JavadocProvider> javadocProvider;
 
     /**
-     * The Basic error controller.
+     * The Context.
      */
-    private static Class<?> basicErrorController;
+    private ApplicationContext context;
 
-    static {
-        try {
-            //spring-boot 2
-            basicErrorController = Class.forName("org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController");
-        } catch (ClassNotFoundException e) {
-            //spring-boot 1
-            try {
-                basicErrorController = Class.forName("org.springframework.boot.autoconfigure.web.BasicErrorController");
-            } catch (ClassNotFoundException classNotFoundException) {
-                //Basic error controller class not found
-                LOGGER.trace(classNotFoundException.getMessage());
-            }
-        }
-    }
+    /**
+     * The Open api.
+     */
+    private OpenAPI openAPI;
+
+    /**
+     * The Is servers present.
+     */
+    private boolean isServersPresent;
+
+    /**
+     * The Server base url.
+     */
+    private String serverBaseUrl;
 
     /**
      * Instantiates a new Open api builder.

--
Gitblit v1.9.3