From a1846a2bd9e1dc78516d2d6cba9d3620c9dbd8f4 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期二, 08 六月 2021 16:20:49 +0800
Subject: [PATCH] 升级swagger到最新版本v3.0.0

---
 src/main/java/com/ruoyi/framework/config/SwaggerConfig.java |   12 +++---
 pom.xml                                                     |   55 +++++++++------------------
 2 files changed, 24 insertions(+), 43 deletions(-)

diff --git a/pom.xml b/pom.xml
index 7aaa7eb..c07c413 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,7 +34,7 @@
 		<bitwalker.version>1.21</bitwalker.version>
 		<jwt.version>0.9.1</jwt.version>
 		<kaptcha.version>2.3.2</kaptcha.version>
-		<swagger.version>2.9.2</swagger.version>
+		<swagger.version>3.0.0</swagger.version>
 		<poi.version>4.1.2</poi.version>
 		<oshi.version>5.6.0</oshi.version>
         <jna.version>5.7.0</jna.version>
@@ -114,27 +114,27 @@
 			<version>${pagehelper.spring.boot.starter.version}</version>
 		</dependency>
 
-		<!--闃块噷鏁版嵁搴撹繛鎺ユ睜 -->
+		<!-- 闃块噷鏁版嵁搴撹繛鎺ユ睜 -->
 		<dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>druid-spring-boot-starter</artifactId>
             <version>${druid.version}</version>
         </dependency>
 
-		<!--甯哥敤宸ュ叿绫� -->
+		<!-- 甯哥敤宸ュ叿绫� -->
 		<dependency>
 			<groupId>org.apache.commons</groupId>
 			<artifactId>commons-lang3</artifactId>
 		</dependency>
 
-		<!--io甯哥敤宸ュ叿绫� -->
+		<!-- io甯哥敤宸ュ叿绫� -->
 		<dependency>
 			<groupId>commons-io</groupId>
 			<artifactId>commons-io</artifactId>
 			<version>${commons.io.version}</version>
 		</dependency>
 		
-		<!--鏂囦欢涓婁紶宸ュ叿绫� -->
+		<!-- 鏂囦欢涓婁紶宸ュ叿绫� -->
 		<dependency>
 			<groupId>commons-fileupload</groupId>
 			<artifactId>commons-fileupload</artifactId>
@@ -155,55 +155,36 @@
 			<version>${fastjson.version}</version>
 		</dependency>
 
-		<!--Spring妗嗘灦鍩烘湰鐨勬牳蹇冨伐鍏�-->
+		<!-- Spring妗嗘灦鍩烘湰鐨勬牳蹇冨伐鍏�-->
 		<dependency>
 			<groupId>org.springframework</groupId>
 			<artifactId>spring-context-support</artifactId>
 		</dependency>
 		
-        <!--Token鐢熸垚涓庤В鏋�-->
+        <!-- Token鐢熸垚涓庤В鏋�-->
 		<dependency>
 			<groupId>io.jsonwebtoken</groupId>
 			<artifactId>jjwt</artifactId>
 			<version>${jwt.version}</version>
 		</dependency>
 		
-		<!-- swagger2-->
-		<dependency>
-			<groupId>io.springfox</groupId>
-			<artifactId>springfox-swagger2</artifactId>
-			<version>${swagger.version}</version>
-			<exclusions>
-			    <exclusion>
-			        <groupId>io.swagger</groupId>
-			        <artifactId>swagger-annotations</artifactId>
-			    </exclusion>
-			    <exclusion>
-			        <groupId>io.swagger</groupId>
-			        <artifactId>swagger-models</artifactId>
-			    </exclusion>
-			</exclusions>
-		</dependency>
-		
-		<!--闃叉杩涘叆swagger椤甸潰鎶ョ被鍨嬭浆鎹㈤敊璇紝鎺掗櫎2.9.2涓殑寮曠敤锛屾墜鍔ㄥ鍔�1.5.21鐗堟湰-->
+		<!-- Swagger3渚濊禆 -->
         <dependency>
-            <groupId>io.swagger</groupId>
-            <artifactId>swagger-annotations</artifactId>
-            <version>1.5.21</version>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-boot-starter</artifactId>
+            <version>3.0.0</version>
+            <exclusion>
+                <groupId>io.swagger</groupId>
+                <artifactId>swagger-models</artifactId>
+            </exclusion>
         </dependency>
         
+        <!-- 闃叉杩涘叆swagger椤甸潰鎶ョ被鍨嬭浆鎹㈤敊璇紝鎺掗櫎3.0.0涓殑寮曠敤锛屾墜鍔ㄥ鍔�1.6.2鐗堟湰 -->
         <dependency>
             <groupId>io.swagger</groupId>
             <artifactId>swagger-models</artifactId>
-            <version>1.5.21</version>
+            <version>1.6.2</version>
         </dependency>
-        
-		<!-- swagger2-UI-->
-		<dependency>
-			<groupId>io.springfox</groupId>
-			<artifactId>springfox-swagger-ui</artifactId>
-			<version>${swagger.version}</version>
-		</dependency>
 		
         <!-- 鑾峰彇绯荤粺淇℃伅 -->
 		<dependency>
@@ -251,7 +232,7 @@
 			</exclusions>
 		</dependency>
 		
-		<!--楠岃瘉鐮� -->
+		<!-- 楠岃瘉鐮� -->
         <dependency>
             <groupId>com.github.penggle</groupId>
             <artifactId>kaptcha</artifactId>
diff --git a/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java b/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java
index 9692685..1abb971 100644
--- a/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java
+++ b/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java
@@ -7,6 +7,7 @@
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.models.auth.In;
 import springfox.documentation.builders.ApiInfoBuilder;
 import springfox.documentation.builders.PathSelectors;
 import springfox.documentation.builders.RequestHandlerSelectors;
@@ -15,10 +16,10 @@
 import springfox.documentation.service.AuthorizationScope;
 import springfox.documentation.service.Contact;
 import springfox.documentation.service.SecurityReference;
+import springfox.documentation.service.SecurityScheme;
 import springfox.documentation.spi.DocumentationType;
 import springfox.documentation.spi.service.contexts.SecurityContext;
 import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
 /**
  * Swagger2鐨勬帴鍙i厤缃�
@@ -26,7 +27,6 @@
  * @author ruoyi
  */
 @Configuration
-@EnableSwagger2
 public class SwaggerConfig
 {
     /** 绯荤粺鍩虹閰嶇疆 */
@@ -70,10 +70,10 @@
     /**
      * 瀹夊叏妯″紡锛岃繖閲屾寚瀹歵oken閫氳繃Authorization澶磋姹傚ご浼犻��
      */
-    private List<ApiKey> securitySchemes()
+    private List<SecurityScheme> securitySchemes()
     {
-        List<ApiKey> apiKeyList = new ArrayList<ApiKey>();
-        apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
+        List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
+        apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
         return apiKeyList;
     }
 
@@ -86,7 +86,7 @@
         securityContexts.add(
                 SecurityContext.builder()
                         .securityReferences(defaultAuth())
-                        .forPaths(PathSelectors.regex("^(?!auth).*$"))
+                        .operationSelector(o -> o.requestMappingPattern().matches("/.*"))
                         .build());
         return securityContexts;
     }

--
Gitblit v1.9.3