From f1937d3968b48616ef1b7a845d32422e08e23ecd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=90=B4=E6=B3=BD=E5=A8=81?= <958142070@qq.com>
Date: Mon, 20 Oct 2025 16:06:45 +0800
Subject: [PATCH] =?UTF-8?q?refactor(web):=20=E7=A7=BB=E9=99=A4=20SpringDoc?=
=?UTF-8?q?=20=E5=85=A8=E5=B1=80=E5=93=8D=E5=BA=94=E5=A4=84=E7=90=86?=
=?UTF-8?q?=E5=99=A8=E5=8F=8A=E7=9B=B8=E5=85=B3=E4=BE=9D=E8=B5=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 删除 ApiDocGlobalResponseHandler 类及其相关配置
- 移除对 continew-starter-api-doc 模块的依赖
- 替换为 swagger-annotations-jakarta 依赖
- 清理 GlobalResponseAutoConfiguration 中的条件加载逻辑
- 更新 pom.xml 中的注释说明
---
continew-starter-web/pom.xml | 7 +-
.../response/ApiDocGlobalResponseHandler.java | 71 -------------------
.../GlobalResponseAutoConfiguration.java | 14 ----
3 files changed, 3 insertions(+), 89 deletions(-)
delete mode 100644 continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/ApiDocGlobalResponseHandler.java
diff --git a/continew-starter-web/pom.xml b/continew-starter-web/pom.xml
index 9a6fe5a3..edb317dc 100644
--- a/continew-starter-web/pom.xml
+++ b/continew-starter-web/pom.xml
@@ -22,11 +22,10 @@
continew-starter-json-jackson
-
+
- top.continew.starter
- continew-starter-api-doc
- true
+ io.swagger.core.v3
+ swagger-annotations-jakarta
diff --git a/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/ApiDocGlobalResponseHandler.java b/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/ApiDocGlobalResponseHandler.java
deleted file mode 100644
index fd0c2f16..00000000
--- a/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/ApiDocGlobalResponseHandler.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
- *
- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package top.continew.starter.web.autoconfigure.response;
-
-import cn.hutool.core.util.ClassUtil;
-import org.apache.commons.lang3.reflect.TypeUtils;
-import org.springdoc.core.parsers.ReturnTypeParser;
-import org.springframework.core.MethodParameter;
-import top.continew.starter.apidoc.util.ApiDocUtils;
-
-import java.lang.reflect.Type;
-
-/**
- * SpringDoc 全局响应处理器
- *
- * 接口文档全局添加响应格式 {@link com.feiniaojin.gracefulresponse.data.Response}
- *
- *
- * @author echo
- * @since 2.5.2
- */
-public class ApiDocGlobalResponseHandler implements ReturnTypeParser {
-
- private final GlobalResponseProperties globalResponseProperties;
- private final Class responseClass;
-
- public ApiDocGlobalResponseHandler(GlobalResponseProperties globalResponseProperties) {
- this.globalResponseProperties = globalResponseProperties;
- this.responseClass = ClassUtil.loadClass(globalResponseProperties.getResponseClassFullName());
- }
-
- /**
- * 获取返回类型
- *
- * @param methodParameter 方法参数
- * @return {@link Type }
- */
- @Override
- public Type getReturnType(MethodParameter methodParameter) {
- // 获取返回类型
- Type returnType = ReturnTypeParser.super.getReturnType(methodParameter);
- // 判断是否具有 RestController 注解
- if (!ApiDocUtils.hasRestControllerAnnotation(methodParameter.getContainingClass())) {
- return returnType;
- }
- // 如果为响应类型,则直接返回
- if (returnType.getTypeName().contains(globalResponseProperties.getResponseClassFullName())) {
- return returnType;
- }
- // 如果是 void类型,则返回 R
- if (returnType == void.class || returnType == Void.class) {
- return TypeUtils.parameterize(responseClass, Void.class);
- }
- // 返回 R
- return TypeUtils.parameterize(responseClass, returnType);
- }
-}
diff --git a/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/GlobalResponseAutoConfiguration.java b/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/GlobalResponseAutoConfiguration.java
index 90803037..fab16995 100644
--- a/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/GlobalResponseAutoConfiguration.java
+++ b/continew-starter-web/src/main/java/top/continew/starter/web/autoconfigure/response/GlobalResponseAutoConfiguration.java
@@ -28,8 +28,6 @@ import com.feiniaojin.gracefulresponse.defaults.DefaultResponseStatusFactoryImpl
import jakarta.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springdoc.core.parsers.ReturnTypeParser;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -223,18 +221,6 @@ public class GlobalResponseAutoConfiguration {
return new AdviceSupport();
}
- /**
- * SpringDoc 全局响应处理器
- *
- * @return {@link ApiDocGlobalResponseHandler }
- */
- @Bean
- @ConditionalOnClass(ReturnTypeParser.class)
- @ConditionalOnMissingBean
- public ApiDocGlobalResponseHandler apiDocGlobalResponseHandler() {
- return new ApiDocGlobalResponseHandler(globalResponseProperties);
- }
-
@PostConstruct
public void postConstruct() {
log.debug("[ContiNew Starter] - Auto Configuration 'Web-Global Response' completed initialization.");