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.");