作者 RuoYi

升级swagger到最新版本v3.0.0

@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> 20 <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
21 <druid.version>1.2.6</druid.version> 21 <druid.version>1.2.6</druid.version>
22 <bitwalker.version>1.21</bitwalker.version> 22 <bitwalker.version>1.21</bitwalker.version>
23 - <swagger.version>2.9.2</swagger.version> 23 + <swagger.version>3.0.0</swagger.version>
24 <kaptcha.version>2.3.2</kaptcha.version> 24 <kaptcha.version>2.3.2</kaptcha.version>
25 <mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version> 25 <mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version>
26 <pagehelper.boot.version>1.3.0</pagehelper.boot.version> 26 <pagehelper.boot.version>1.3.0</pagehelper.boot.version>
@@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
48 <scope>import</scope> 48 <scope>import</scope>
49 </dependency> 49 </dependency>
50 50
51 - <!--阿里数据库连接池 --> 51 + <!-- 阿里数据库连接池 -->
52 <dependency> 52 <dependency>
53 <groupId>com.alibaba</groupId> 53 <groupId>com.alibaba</groupId>
54 <artifactId>druid-spring-boot-starter</artifactId> 54 <artifactId>druid-spring-boot-starter</artifactId>
@@ -95,38 +95,25 @@ @@ -95,38 +95,25 @@
95 <version>${jna.version}</version> 95 <version>${jna.version}</version>
96 </dependency> 96 </dependency>
97 97
98 - <!-- swagger2--> 98 + <!-- Swagger3依赖 -->
99 <dependency> 99 <dependency>
100 <groupId>io.springfox</groupId> 100 <groupId>io.springfox</groupId>
101 - <artifactId>springfox-swagger2</artifactId>  
102 - <version>${swagger.version}</version>  
103 - <exclusions>  
104 - <exclusion>  
105 - <groupId>io.swagger</groupId>  
106 - <artifactId>swagger-annotations</artifactId>  
107 - </exclusion>  
108 - <exclusion>  
109 - <groupId>io.swagger</groupId>  
110 - <artifactId>swagger-models</artifactId>  
111 - </exclusion>  
112 - </exclusions>  
113 - </dependency>  
114 -  
115 - <!-- swagger2-UI-->  
116 - <dependency>  
117 - <groupId>io.springfox</groupId>  
118 - <artifactId>springfox-swagger-ui</artifactId>  
119 - <version>${swagger.version}</version> 101 + <artifactId>springfox-boot-starter</artifactId>
  102 + <version>3.0.0</version>
  103 + <exclusion>
  104 + <groupId>io.swagger</groupId>
  105 + <artifactId>swagger-models</artifactId>
  106 + </exclusion>
120 </dependency> 107 </dependency>
121 108
122 - <!--io常用工具类 --> 109 + <!-- io常用工具类 -->
123 <dependency> 110 <dependency>
124 <groupId>commons-io</groupId> 111 <groupId>commons-io</groupId>
125 <artifactId>commons-io</artifactId> 112 <artifactId>commons-io</artifactId>
126 <version>${commons.io.version}</version> 113 <version>${commons.io.version}</version>
127 </dependency> 114 </dependency>
128 115
129 - <!--文件上传工具类 --> 116 + <!-- 文件上传工具类 -->
130 <dependency> 117 <dependency>
131 <groupId>commons-fileupload</groupId> 118 <groupId>commons-fileupload</groupId>
132 <artifactId>commons-fileupload</artifactId> 119 <artifactId>commons-fileupload</artifactId>
@@ -140,7 +127,7 @@ @@ -140,7 +127,7 @@
140 <version>${poi.version}</version> 127 <version>${poi.version}</version>
141 </dependency> 128 </dependency>
142 129
143 - <!--velocity代码生成使用模板 --> 130 + <!-- velocity代码生成使用模板 -->
144 <dependency> 131 <dependency>
145 <groupId>org.apache.velocity</groupId> 132 <groupId>org.apache.velocity</groupId>
146 <artifactId>velocity</artifactId> 133 <artifactId>velocity</artifactId>
@@ -167,14 +154,14 @@ @@ -167,14 +154,14 @@
167 <version>${fastjson.version}</version> 154 <version>${fastjson.version}</version>
168 </dependency> 155 </dependency>
169 156
170 - <!--Token生成与解析--> 157 + <!-- Token生成与解析-->
171 <dependency> 158 <dependency>
172 <groupId>io.jsonwebtoken</groupId> 159 <groupId>io.jsonwebtoken</groupId>
173 <artifactId>jjwt</artifactId> 160 <artifactId>jjwt</artifactId>
174 <version>${jwt.version}</version> 161 <version>${jwt.version}</version>
175 </dependency> 162 </dependency>
176 163
177 - <!--验证码 --> 164 + <!-- 验证码 -->
178 <dependency> 165 <dependency>
179 <groupId>com.github.penggle</groupId> 166 <groupId>com.github.penggle</groupId>
180 <artifactId>kaptcha</artifactId> 167 <artifactId>kaptcha</artifactId>
@@ -24,29 +24,17 @@ @@ -24,29 +24,17 @@
24 <optional>true</optional> <!-- 表示依赖不会传递 --> 24 <optional>true</optional> <!-- 表示依赖不会传递 -->
25 </dependency> 25 </dependency>
26 26
27 - <!-- swagger2--> 27 + <!-- swagger3-->
28 <dependency> 28 <dependency>
29 <groupId>io.springfox</groupId> 29 <groupId>io.springfox</groupId>
30 - <artifactId>springfox-swagger2</artifactId>  
31 - </dependency>  
32 -  
33 - <!--防止进入swagger页面报类型转换错误,排除2.9.2中的引用,手动增加1.5.21版本-->  
34 - <dependency>  
35 - <groupId>io.swagger</groupId>  
36 - <artifactId>swagger-annotations</artifactId>  
37 - <version>1.5.21</version> 30 + <artifactId>springfox-boot-starter</artifactId>
38 </dependency> 31 </dependency>
39 32
  33 + <!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
40 <dependency> 34 <dependency>
41 <groupId>io.swagger</groupId> 35 <groupId>io.swagger</groupId>
42 <artifactId>swagger-models</artifactId> 36 <artifactId>swagger-models</artifactId>
43 - <version>1.5.21</version>  
44 - </dependency>  
45 -  
46 - <!-- swagger2-UI-->  
47 - <dependency>  
48 - <groupId>io.springfox</groupId>  
49 - <artifactId>springfox-swagger-ui</artifactId> 37 + <version>1.6.2</version>
50 </dependency> 38 </dependency>
51 39
52 <!-- Mysql驱动包 --> 40 <!-- Mysql驱动包 -->
@@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean; @@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean;
8 import org.springframework.context.annotation.Configuration; 8 import org.springframework.context.annotation.Configuration;
9 import com.ruoyi.common.config.RuoYiConfig; 9 import com.ruoyi.common.config.RuoYiConfig;
10 import io.swagger.annotations.ApiOperation; 10 import io.swagger.annotations.ApiOperation;
  11 +import io.swagger.models.auth.In;
11 import springfox.documentation.builders.ApiInfoBuilder; 12 import springfox.documentation.builders.ApiInfoBuilder;
12 import springfox.documentation.builders.PathSelectors; 13 import springfox.documentation.builders.PathSelectors;
13 import springfox.documentation.builders.RequestHandlerSelectors; 14 import springfox.documentation.builders.RequestHandlerSelectors;
@@ -16,10 +17,10 @@ import springfox.documentation.service.ApiKey; @@ -16,10 +17,10 @@ import springfox.documentation.service.ApiKey;
16 import springfox.documentation.service.AuthorizationScope; 17 import springfox.documentation.service.AuthorizationScope;
17 import springfox.documentation.service.Contact; 18 import springfox.documentation.service.Contact;
18 import springfox.documentation.service.SecurityReference; 19 import springfox.documentation.service.SecurityReference;
  20 +import springfox.documentation.service.SecurityScheme;
19 import springfox.documentation.spi.DocumentationType; 21 import springfox.documentation.spi.DocumentationType;
20 import springfox.documentation.spi.service.contexts.SecurityContext; 22 import springfox.documentation.spi.service.contexts.SecurityContext;
21 import springfox.documentation.spring.web.plugins.Docket; 23 import springfox.documentation.spring.web.plugins.Docket;
22 -import springfox.documentation.swagger2.annotations.EnableSwagger2;  
23 24
24 /** 25 /**
25 * Swagger2的接口配置 26 * Swagger2的接口配置
@@ -27,7 +28,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @@ -27,7 +28,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
27 * @author ruoyi 28 * @author ruoyi
28 */ 29 */
29 @Configuration 30 @Configuration
30 -@EnableSwagger2  
31 public class SwaggerConfig 31 public class SwaggerConfig
32 { 32 {
33 /** 系统基础配置 */ 33 /** 系统基础配置 */
@@ -71,10 +71,10 @@ public class SwaggerConfig @@ -71,10 +71,10 @@ public class SwaggerConfig
71 /** 71 /**
72 * 安全模式,这里指定token通过Authorization头请求头传递 72 * 安全模式,这里指定token通过Authorization头请求头传递
73 */ 73 */
74 - private List<ApiKey> securitySchemes() 74 + private List<SecurityScheme> securitySchemes()
75 { 75 {
76 - List<ApiKey> apiKeyList = new ArrayList<ApiKey>();  
77 - apiKeyList.add(new ApiKey("Authorization", "Authorization", "header")); 76 + List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
  77 + apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
78 return apiKeyList; 78 return apiKeyList;
79 } 79 }
80 80
@@ -87,7 +87,7 @@ public class SwaggerConfig @@ -87,7 +87,7 @@ public class SwaggerConfig
87 securityContexts.add( 87 securityContexts.add(
88 SecurityContext.builder() 88 SecurityContext.builder()
89 .securityReferences(defaultAuth()) 89 .securityReferences(defaultAuth())
90 - .forPaths(PathSelectors.regex("^(?!auth).*$")) 90 + .operationSelector(o -> o.requestMappingPattern().matches("/.*"))
91 .build()); 91 .build());
92 return securityContexts; 92 return securityContexts;
93 } 93 }
@@ -158,7 +158,6 @@ export default { @@ -158,7 +158,6 @@ export default {
158 }); 158 });
159 }, 159 },
160 handleUploadSuccess(res, file) { 160 handleUploadSuccess(res, file) {
161 - console.info(file);  
162 // 获取富文本组件实例 161 // 获取富文本组件实例
163 let quill = this.Quill; 162 let quill = this.Quill;
164 // 如果上传成功 163 // 如果上传成功
@@ -8,7 +8,7 @@ export default { @@ -8,7 +8,7 @@ export default {
8 name: "Swagger", 8 name: "Swagger",
9 data() { 9 data() {
10 return { 10 return {
11 - src: process.env.VUE_APP_BASE_API + "/swagger-ui.html", 11 + src: process.env.VUE_APP_BASE_API + "/swagger-ui/index.html",
12 height: document.documentElement.clientHeight - 94.5 + "px;", 12 height: document.documentElement.clientHeight - 94.5 + "px;",
13 loading: true 13 loading: true
14 }; 14 };