diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml
index af759726f..a29a0052f 100644
--- a/yudao-dependencies/pom.xml
+++ b/yudao-dependencies/pom.xml
@@ -18,7 +18,8 @@
2.7.7
- 4.0.0
+ 1.6.14
+
2.5
1.2.15
@@ -163,10 +164,15 @@
${revision}
+
+
+
+
+
- com.github.xiaoymin
- knife4j-openapi3-spring-boot-starter
- ${knife4j.version}
+ org.springdoc
+ springdoc-openapi-ui
+ ${springdoc.version}
@@ -276,16 +282,16 @@
org.apache.skywalking
apm-toolkit-opentracing
${skywalking.version}
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
io.opentracing
@@ -448,7 +454,7 @@
org.freemarker
freemarker
-
+
com.alibaba
fastjson
diff --git a/yudao-framework/yudao-common/pom.xml b/yudao-framework/yudao-common/pom.xml
index 24fc39dec..0bf582993 100644
--- a/yudao-framework/yudao-common/pom.xml
+++ b/yudao-framework/yudao-common/pom.xml
@@ -58,10 +58,16 @@
provided
+
+
+
+
- com.github.xiaoymin
- knife4j-openapi3-spring-boot-starter
+ org.springdoc
+ springdoc-openapi-ui
+ provided
+
org.apache.skywalking
diff --git a/yudao-framework/yudao-spring-boot-starter-web/pom.xml b/yudao-framework/yudao-spring-boot-starter-web/pom.xml
index 89d35f44f..31bf43e12 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-web/pom.xml
@@ -33,9 +33,13 @@
true
+
+
+
+
- com.github.xiaoymin
- knife4j-openapi3-spring-boot-starter
+ org.springdoc
+ springdoc-openapi-ui
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java
index a064ee46d..313b60010 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java
@@ -1,9 +1,12 @@
package cn.iocoder.yudao.framework.swagger.config;
-import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
+import io.swagger.v3.oas.models.media.IntegerSchema;
+import io.swagger.v3.oas.models.parameters.Parameter;
+import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springdoc.core.GroupedOpenApi;
import org.springdoc.core.*;
@@ -17,10 +20,11 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpHeaders;
-import java.util.Arrays;
import java.util.List;
import java.util.Optional;
+import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_TENANT_ID;
+
/**
* Swagger3 自动配置类
*
@@ -40,20 +44,23 @@ public class YudaoSwaggerAutoConfiguration {
.title(properties.getTitle())
.description(properties.getDescription())
.version(properties.getVersion())
+ .contact(new Contact().name("xingyuv").url("xingyuv.com").email("xingyu4j@vip.qq.com"))
.license(new License().name("MIT").url("https://gitee.com/zhijiantianya/ruoyi-vue-pro/blob/master/LICENSE"));
- //鉴权组件(随便起名的)
- SecurityScheme securityScheme = new SecurityScheme()
- .type(SecurityScheme.Type.APIKEY)
- .scheme("Bearer")//固定写法
- .bearerFormat("JWT")
- .in(SecurityScheme.In.HEADER)
- .name(HttpHeaders.AUTHORIZATION);
- Components components = new Components()
- .addSecuritySchemes("bearer", securityScheme);
-
return new OpenAPI()
.info(info)
- .components(components);
+ .schemaRequirement(HttpHeaders.AUTHORIZATION, securityScheme())
+ .addSecurityItem(new SecurityRequirement().addList(HttpHeaders.AUTHORIZATION));
+ }
+
+ private SecurityScheme securityScheme() {
+ SecurityScheme securityScheme = new SecurityScheme();
+ //类型
+ securityScheme.setType(SecurityScheme.Type.APIKEY);
+ //请求头的name
+ securityScheme.setName(HttpHeaders.AUTHORIZATION);
+ //token所在未知
+ securityScheme.setIn(SecurityScheme.In.HEADER);
+ return securityScheme;
}
/**
@@ -74,6 +81,9 @@ public class YudaoSwaggerAutoConfiguration {
public GroupedOpenApi appApi() {
return GroupedOpenApi.builder()
.group("app")
+ .addOperationCustomizer((operation, handlerMethod) ->
+ operation.addParametersItem(globalHeaderParameter())
+ )
.pathsToMatch("/app-api/**")
.build();
}
@@ -82,9 +92,24 @@ public class YudaoSwaggerAutoConfiguration {
public GroupedOpenApi adminApi() {
return GroupedOpenApi.builder()
.group("admin")
+ .addOperationCustomizer((operation, handlerMethod) ->
+ operation.addParametersItem(globalHeaderParameter())
+ )
.pathsToMatch("/admin-api/**")
.build();
}
+ private static Parameter globalHeaderParameter() {
+ return new Parameter()
+ .name(HEADER_TENANT_ID)
+ .description("租户编号")
+ .in(String.valueOf(SecurityScheme.In.HEADER))
+ .schema(new IntegerSchema()
+ ._default(1L)
+ .name(HEADER_TENANT_ID)
+ .description("租户编号")
+ );
+ }
+
}
diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml
index 0cc0d271e..a14208ea0 100644
--- a/yudao-server/src/main/resources/application.yaml
+++ b/yudao-server/src/main/resources/application.yaml
@@ -37,14 +37,17 @@ spring:
springdoc:
show-actuator: true
swagger-ui:
+ enabled: true
path: /swagger-ui
api-docs:
+ enabled: true
path: /v3/api-docs
-knife4j:
- enable: true
- setting:
- language: zh_cn
+
+#knife4j:
+# enable: true
+# setting:
+# language: zh_cn
# 工作流 Flowable 配置
flowable:
diff --git a/yudao-ui-admin-vue3/src/views/infra/swagger/index.vue b/yudao-ui-admin-vue3/src/views/infra/swagger/index.vue
index 5d4697c1a..574e9ddd2 100644
--- a/yudao-ui-admin-vue3/src/views/infra/swagger/index.vue
+++ b/yudao-ui-admin-vue3/src/views/infra/swagger/index.vue
@@ -8,5 +8,5 @@ import { ref } from 'vue'
import { IFrame } from '@/components/IFrame'
const BASE_URL = import.meta.env.VITE_BASE_URL
-const src = ref(BASE_URL + '/doc.html')
+const src = ref(BASE_URL + '/swagger-ui')