From 0ebba2eb8116e4da42753f0e2c732e137baade9a Mon Sep 17 00:00:00 2001 From: xingyu Date: Tue, 17 Jan 2023 20:47:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4springfox=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/YudaoSwaggerAutoConfiguration.java | 6 +-- ...ngFoxHandlerProviderBeanPostProcessor.java | 43 ------------------- 2 files changed, 2 insertions(+), 47 deletions(-) delete mode 100644 yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/core/SpringFoxHandlerProviderBeanPostProcessor.java 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 0eb39b7ce..fec3e21e6 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 @@ -15,7 +15,6 @@ import org.springdoc.core.customizers.ServerBaseUrlCustomizer; import org.springdoc.core.providers.JavadocProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.http.HttpHeaders; @@ -26,14 +25,13 @@ import java.util.Optional; import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_TENANT_ID; /** - * Swagger3 自动配置类 + * springdoc 自动配置类 + * 使用 knife4j.enable=false 禁用 Swagger * * @author 芋道源码 */ @AutoConfiguration @ConditionalOnClass({OpenAPI.class}) -// 允许使用 swagger.enable=false 禁用 Swagger -@ConditionalOnProperty(prefix = "yudao.swagger", value = "enable", matchIfMissing = true) @EnableConfigurationProperties(SwaggerProperties.class) public class YudaoSwaggerAutoConfiguration { diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/core/SpringFoxHandlerProviderBeanPostProcessor.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/core/SpringFoxHandlerProviderBeanPostProcessor.java deleted file mode 100644 index 4eea3cc36..000000000 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/core/SpringFoxHandlerProviderBeanPostProcessor.java +++ /dev/null @@ -1,43 +0,0 @@ -//package cn.iocoder.yudao.framework.swagger.core; -// -//import cn.hutool.core.util.ReflectUtil; -//import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -//import org.springframework.beans.BeansException; -//import org.springframework.beans.factory.config.BeanPostProcessor; -//import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; -//import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider; -//import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider; -// -//import java.util.List; -// -///** -// * 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题 -// * 该问题对应的 issue 为 https://github.com/springfox/springfox/issues/3462 -// * -// * @author 芋道源码 -// */ -//public class SpringFoxHandlerProviderBeanPostProcessor implements BeanPostProcessor { -// -// @Override -// public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { -// if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) { -// customizeSpringfoxHandlerMappings(getHandlerMappings(bean)); -// } -// return bean; -// } -// -// private void customizeSpringfoxHandlerMappings(List mappings) { -// // 移除,只保留 patternParser -// List copy = CollectionUtils.filterList(mappings, mapping -> mapping.getPatternParser() == null); -// // 添加到 mappings 中 -// mappings.clear(); -// mappings.addAll(copy); -// } -// -// @SuppressWarnings("unchecked") -// private List getHandlerMappings(Object bean) { -// return (List) -// ReflectUtil.getFieldValue(bean, "handlerMappings"); -// } -// -//}