优化 Swagger 的版本依赖,避免冲突

This commit is contained in:
YunaiV 2023-03-04 15:05:58 +08:00
parent e28d73a76c
commit 59c6963f7c
17 changed files with 135 additions and 77 deletions

View File

@ -16,14 +16,14 @@
<properties>
<revision>1.6.6-snapshot</revision>
<!-- 统一依赖管理 -->
<spring.boot.version>2.7.7</spring.boot.version>
<spring.boot.version>2.7.8</spring.boot.version>
<spring.cloud.version>2021.0.5</spring.cloud.version>
<spring.cloud.alibaba.version>2021.0.4.0</spring.cloud.alibaba.version>
<!-- Web 相关 -->
<knife4j.version>4.0.0</knife4j.version>
<swagger-annotations.version>1.6.8</swagger-annotations.version>
<servlet.versoin>2.5</servlet.versoin>
<swagger.version>2.2.8</swagger.version>
<springdoc.version>1.6.14</springdoc.version>
<knife4j.version>4.0.0</knife4j.version>
<!-- DB 相关 -->
<druid.version>1.2.15</druid.version>
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
@ -199,15 +199,39 @@
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webflux-ui</artifactId>
<version>1.6.14</version>
<groupId>io.swagger.core.v3</groupId> <!-- 接口文档:使用最新版本的 Swagger 模型 -->
<artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<groupId>io.swagger.core.v3</groupId> <!-- 接口文档:使用最新版本的 Swagger 模型 -->
<artifactId>swagger-models</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId> <!-- 接口文档 UI解决 knife4j 引入的 Spring Doc 版本太老 -->
<artifactId>springdoc-openapi-common</artifactId>
<version>${springdoc.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId> <!-- 接口文档 UI解决 knife4j 引入的 Spring Doc 版本太老 -->
<artifactId>springdoc-openapi-webmvc-core</artifactId>
<version>1.6.14</version>
<version>${springdoc.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId> <!-- 接口文档 UI解决 knife4j 引入的 Spring Doc 版本太老 -->
<artifactId>springdoc-openapi-webflux-core</artifactId>
<version>${springdoc.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId> <!-- 接口文档 UI默认 -->
<artifactId>springdoc-openapi-ui</artifactId>
<version>${springdoc.version}</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId> <!-- 接口文档 UIknife4j -->
<artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
<version>${knife4j.version}</version>
</dependency>
<!-- DB 相关 -->
@ -216,6 +240,11 @@
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
<version>${revision}</version>
</dependency>
<dependency> <!-- TODO 芋艿:说不清楚 -->
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webflux-ui</artifactId>
<version>${springdoc.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>

View File

@ -59,9 +59,9 @@
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
<scope>compile</scope>
<groupId>io.swagger.core.v3</groupId> <!-- 接口文档:使用最新版本的 Swagger 模型 -->
<artifactId>swagger-annotations</artifactId>
<scope>provided</scope>
</dependency>
<!-- 监控相关 -->

View File

@ -21,9 +21,11 @@
<artifactId>yudao-common</artifactId>
</dependency>
<!-- Spring Boot 配置所需依赖 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- Web 相关 -->
@ -31,12 +33,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- spring boot 配置所需依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -49,6 +45,15 @@
<scope>provided</scope> <!-- 设置为 provided主要是 GlobalExceptionHandler 使用 -->
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId> <!-- 接口文档 -->
<artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId> <!-- 接口文档 -->
<artifactId>springdoc-openapi-ui</artifactId>
</dependency>
<!-- RPC 远程调用相关 -->
<dependency>
<groupId>cn.iocoder.cloud</groupId>

View File

@ -1,28 +0,0 @@
package cn.iocoder.yudao.module.bpm.framework.bpm.config;
import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
/**
* @author kemengkai
* @create 2022-05-07 08:15
*/
@Configuration(proxyBeanMethods = false, value = "bpmSecurityConfiguration")
public class BpmSecurityConfiguration {
@Bean("bpmAuthorizeRequestsCustomizer")
public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() {
return new AuthorizeRequestsCustomizer() {
@Override
public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {
// 任务回退接口
registry.antMatchers(buildAdminApi("/bpm/task/back")).permitAll();
}
};
}
}

View File

@ -21,10 +21,8 @@ public class SecurityConfiguration {
public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {
// TODO 芋艿这个每个项目都需要重复配置得捉摸有没通用的方案
// Swagger 接口文档
registry.antMatchers("/swagger-ui.html").anonymous()
.antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous()
.antMatchers("/*/api-docs").anonymous();
registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据
.antMatchers("/swagger-ui.html").permitAll(); // Swagger UI
// Druid 监控
registry.antMatchers("/druid/**").anonymous();
// Spring Boot Actuator 的安全配置

View File

@ -27,6 +27,21 @@ spring:
redis:
time-to-live: 1h # 设置过期时间为 1 小时
--- #################### 接口文档配置 ####################
springdoc:
api-docs:
enabled: true # 1. 是否开启 Swagger 接文档的元数据
path: /v3/api-docs
swagger-ui:
enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面
path: /swagger-ui.html
knife4j:
enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面
setting:
language: zh_cn
# 工作流 Flowable 配置
flowable:
# 1. false: 默认值Flowable 启动时,对比数据库表中保存的版本,如果不匹配。将抛出异常

View File

@ -24,8 +24,9 @@
<!-- Web 相关 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
<groupId>io.swagger.core.v3</groupId> <!-- 接口文档:使用最新版本的 Swagger 模型 -->
<artifactId>swagger-annotations</artifactId>
<scope>provided</scope>
</dependency>
<!-- 参数校验 -->

View File

@ -1,7 +1,5 @@
package cn.iocoder.yudao.module.infra;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -24,10 +24,8 @@ public class SecurityConfiguration {
@Override
public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {
// Swagger 接口文档
registry.antMatchers("/swagger-ui.html").anonymous()
.antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous()
.antMatchers("/*/api-docs").anonymous();
registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据
.antMatchers("/swagger-ui.html").permitAll(); // Swagger UI
// Spring Boot Actuator 的安全配置
registry.antMatchers("/actuator").anonymous()
.antMatchers("/actuator/**").anonymous();

View File

@ -27,6 +27,21 @@ spring:
redis:
time-to-live: 1h # 设置过期时间为 1 小时
--- #################### 接口文档配置 ####################
springdoc:
api-docs:
enabled: true # 1. 是否开启 Swagger 接文档的元数据
path: /v3/api-docs
swagger-ui:
enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面
path: /swagger-ui.html
knife4j:
enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面
setting:
language: zh_cn
# MyBatis Plus 的配置项
mybatis-plus:
configuration:

View File

@ -19,10 +19,8 @@ public class SecurityConfiguration {
@Override
public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {
// Swagger 接口文档
registry.antMatchers("/swagger-ui.html").anonymous()
.antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous()
.antMatchers("/*/api-docs").anonymous();
registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据
.antMatchers("/swagger-ui.html").permitAll(); // Swagger UI
// Spring Boot Actuator 的安全配置
registry.antMatchers("/actuator").anonymous()
.antMatchers("/actuator/**").anonymous();

View File

@ -27,6 +27,21 @@ spring:
redis:
time-to-live: 1h # 设置过期时间为 1 小时
--- #################### 接口文档配置 ####################
springdoc:
api-docs:
enabled: true # 1. 是否开启 Swagger 接文档的元数据
path: /v3/api-docs
swagger-ui:
enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面
path: /swagger-ui.html
knife4j:
enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面
setting:
language: zh_cn
# MyBatis Plus 的配置项
mybatis-plus:
configuration:

View File

@ -24,8 +24,9 @@
<!-- Web 相关 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
<groupId>io.swagger.core.v3</groupId> <!-- 接口文档:使用最新版本的 Swagger 模型 -->
<artifactId>swagger-annotations</artifactId>
<scope>provided</scope> <!-- 设置为 provided主要是 PageParam 使用到 -->
</dependency>
<!-- 参数校验 -->

View File

@ -35,12 +35,12 @@ public interface AdminUserApi {
@GetMapping(PREFIX + "/list-by-dept-id")
@Operation(summary = "获得指定部门的用户数组")
@Parameter(name = "deptIds", description = "部门编号数组", example = "1,2", required = true)
CommonResult<List<AdminUserRespDTO>> getUsersByDeptIds(@RequestParam("deptIds") Collection<Long> deptIds);
CommonResult<List<AdminUserRespDTO>> getUserListByDeptIds(@RequestParam("deptIds") Collection<Long> deptIds);
@GetMapping(PREFIX + "/list-by-post-id")
@Operation(summary = "获得指定岗位的用户数组")
@Parameter(name = "postIds", description = "岗位编号数组", example = "2,3", required = true)
CommonResult<List<AdminUserRespDTO>> getUsersByPostIds(@RequestParam("postIds") Collection<Long> postIds);
CommonResult<List<AdminUserRespDTO>> getUserListByPostIds(@RequestParam("postIds") Collection<Long> postIds);
/**
* 获得用户 Map
@ -55,6 +55,6 @@ public interface AdminUserApi {
@GetMapping(PREFIX + "/valid")
@Operation(summary = "校验用户们是否有效")
@Parameter(name = "ids", description = "用户编号数组", example = "3,5", required = true)
CommonResult<Boolean> validUsers(@RequestParam("ids") Set<Long> ids);
CommonResult<Boolean> validUserList(@RequestParam("ids") Set<Long> ids);
}
}

View File

@ -39,19 +39,19 @@ public class AdminUserApiImpl implements AdminUserApi {
}
@Override
public CommonResult<List<AdminUserRespDTO>> getUsersByDeptIds(Collection<Long> deptIds) {
public CommonResult<List<AdminUserRespDTO>> getUserListByDeptIds(Collection<Long> deptIds) {
List<AdminUserDO> users = userService.getUserListByDeptIds(deptIds);
return success(UserConvert.INSTANCE.convertList4(users));
}
@Override
public CommonResult<List<AdminUserRespDTO>> getUsersByPostIds(Collection<Long> postIds) {
public CommonResult<List<AdminUserRespDTO>> getUserListByPostIds(Collection<Long> postIds) {
List<AdminUserDO> users = userService.getUserListByPostIds(postIds);
return success(UserConvert.INSTANCE.convertList4(users));
}
@Override
public CommonResult<Boolean> validUsers(Set<Long> ids) {
public CommonResult<Boolean> validUserList(Set<Long> ids) {
userService.validateUserList(ids);
return success(true);
}

View File

@ -21,10 +21,8 @@ public class SecurityConfiguration {
public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {
// TODO 芋艿这个每个项目都需要重复配置得捉摸有没通用的方案
// Swagger 接口文档
registry.antMatchers("/swagger-ui.html").anonymous()
.antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous()
.antMatchers("/*/api-docs").anonymous();
registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据
.antMatchers("/swagger-ui.html").permitAll(); // Swagger UI
// Druid 监控
registry.antMatchers("/druid/**").anonymous();
// Spring Boot Actuator 的安全配置

View File

@ -27,6 +27,21 @@ spring:
redis:
time-to-live: 1h # 设置过期时间为 1 小时
--- #################### 接口文档配置 ####################
springdoc:
api-docs:
enabled: true # 1. 是否开启 Swagger 接文档的元数据
path: /v3/api-docs
swagger-ui:
enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面
path: /swagger-ui.html
knife4j:
enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面
setting:
language: zh_cn
# MyBatis Plus 的配置项
mybatis-plus:
configuration: