From 49c9572a3b5b7582daa35db342888a2a2a18b906 Mon Sep 17 00:00:00 2001 From: tanghc Date: Tue, 31 Mar 2020 15:13:04 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sop/websiteserver/manager/SwaggerDocParser.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sop-website/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java b/sop-website/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java index af3b419a..c7e366d2 100644 --- a/sop-website/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java +++ b/sop-website/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java @@ -148,8 +148,15 @@ public class SwaggerDocParser implements DocParser { List docParameterList = new ArrayList<>(); for (int i = 0; i < parameters.size(); i++) { JSONObject fieldJson = parameters.getJSONObject(i); - DocParameter docParameter = fieldJson.toJavaObject(DocParameter.class); - docParameterList.add(docParameter); + JSONObject schema = fieldJson.getJSONObject("schema"); + if (schema != null) { + RefInfo refInfo = getRefInfo(schema); + List parameterList = this.buildDocParameters(refInfo.ref, docRoot, true); + docParameterList.addAll(parameterList); + } else { + DocParameter docParameter = fieldJson.toJavaObject(DocParameter.class); + docParameterList.add(docParameter); + } } Map> collect = docParameterList.stream() From 8e20db45144181a1188802c4c0d1a536b56dfeec Mon Sep 17 00:00:00 2001 From: tanghc Date: Sun, 5 Apr 2020 10:41:05 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=A7=E6=89=BFWebMvcC?= =?UTF-8?q?onfigurationSupport=E5=AF=BC=E8=87=B4=E7=9A=84jackson=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E6=97=B6=E9=97=B4=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=94=E5=9B=9Evoid=E7=BD=91=E5=85=B3=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E8=BF=94=E5=9B=9Ecode=E5=92=8Cmsg=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 5 +++++ .../GatewayModifyResponseGatewayFilter.java | 2 ++ .../configuration/BaseServiceConfiguration.java | 15 +++++++-------- .../sop/bookweb/config/OpenServiceConfig.java | 10 ---------- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/changelog.md b/changelog.md index 0657a6a4..cfc42ddd 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ # changelog +## 3.1.1 + +- 修复继承WebMvcConfigurationSupport导致的jackson序列化时间问题 +- 修复微服务接口返回void网关不会返回code和msg问题 + ## 3.1.0 - 新增路由监控功能 diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/GatewayModifyResponseGatewayFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/GatewayModifyResponseGatewayFilter.java index 974a3a4c..aa248d9c 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/GatewayModifyResponseGatewayFilter.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/GatewayModifyResponseGatewayFilter.java @@ -59,6 +59,8 @@ public class GatewayModifyResponseGatewayFilter implements GlobalFilter, Ordered //TODO: flux or mono Mono modifiedBody = clientResponse.bodyToMono(inClass) + // 修复微服务接口返回void网关不会返回code和msg问题 + .switchIfEmpty(Mono.just("")) .flatMap(originalBody -> { // 合并微服务传递过来的结果,变成最终结果 ResultExecutor resultExecutor = ApiContext.getApiConfig().getGatewayResultExecutor(); diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java index 2520b137..84534a9d 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java @@ -9,13 +9,14 @@ import com.gitee.sop.servercommon.message.ServiceErrorFactory; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations; import org.springframework.context.annotation.Bean; import org.springframework.core.env.Environment; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import javax.annotation.PostConstruct; @@ -26,7 +27,7 @@ import java.util.List; * @author tanghc */ @Slf4j -public class BaseServiceConfiguration extends WebMvcConfigurationSupport { +public class BaseServiceConfiguration implements WebMvcConfigurer, WebMvcRegistrations { public BaseServiceConfiguration() { ServiceConfig.getInstance().getI18nModules().add("i18n/isp/bizerror"); @@ -38,8 +39,7 @@ public class BaseServiceConfiguration extends WebMvcConfigurationSupport { private Environment environment; @Override - protected void addResourceHandlers(ResourceHandlerRegistry registry) { - super.addResourceHandlers(registry); + public void addResourceHandlers(ResourceHandlerRegistry registry) { // 支持swagger-bootstrap-ui首页 registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); // 支持默认swagger @@ -48,14 +48,13 @@ public class BaseServiceConfiguration extends WebMvcConfigurationSupport { } @Override - protected void addInterceptors(InterceptorRegistry registry) { + public void addInterceptors(InterceptorRegistry registry) { // 添加拦截器 registry.addInterceptor(new ServiceContextInterceptor()); - super.addInterceptors(registry); } @Override - protected void extendMessageConverters(List> converters) { + public void extendMessageConverters(List> converters) { // 解决controller返回字符串中文乱码问题 for (HttpMessageConverter converter : converters) { if (converter instanceof StringHttpMessageConverter) { @@ -69,7 +68,7 @@ public class BaseServiceConfiguration extends WebMvcConfigurationSupport { * @return 返回RequestMappingHandlerMapping */ @Override - protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() { + public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { return apiMappingHandlerMapping; } diff --git a/sop-example/sop-book/sop-book-web/src/main/java/com/gitee/sop/bookweb/config/OpenServiceConfig.java b/sop-example/sop-book/sop-book-web/src/main/java/com/gitee/sop/bookweb/config/OpenServiceConfig.java index 2a4ce64a..a84ddea8 100644 --- a/sop-example/sop-book/sop-book-web/src/main/java/com/gitee/sop/bookweb/config/OpenServiceConfig.java +++ b/sop-example/sop-book/sop-book-web/src/main/java/com/gitee/sop/bookweb/config/OpenServiceConfig.java @@ -3,7 +3,6 @@ package com.gitee.sop.bookweb.config; import com.gitee.sop.servercommon.configuration.AlipayServiceConfiguration; import com.gitee.sop.servercommon.swagger.SwaggerSupport; import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import springfox.documentation.swagger2.annotations.EnableSwagger2; /** @@ -13,15 +12,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration public class OpenServiceConfig extends AlipayServiceConfiguration { - @Override - protected void addResourceHandlers(ResourceHandlerRegistry registry) { - super.addResourceHandlers(registry); - registry.addResourceHandler("swagger-ui.html") - .addResourceLocations("classpath:/META-INF/resources/"); - registry.addResourceHandler("/webjars/**") - .addResourceLocations("classpath:/META-INF/resources/webjars/"); - } - // 开启文档 @Configuration @EnableSwagger2 From 53a995a5c52136f7825641d53a03eeec988f9a1c Mon Sep 17 00:00:00 2001 From: tanghc Date: Sun, 5 Apr 2020 10:41:58 +0800 Subject: [PATCH 3/3] 3.1.1 --- sop-auth/pom.xml | 2 +- sop-common/pom.xml | 2 +- sop-common/sop-bridge-gateway/pom.xml | 6 +++--- sop-common/sop-bridge-zuul/pom.xml | 6 +++--- sop-common/sop-gateway-common/pom.xml | 4 ++-- sop-common/sop-service-common/pom.xml | 4 ++-- sop-example/sop-book/sop-book-web/pom.xml | 2 +- sop-example/sop-easyopen/pom.xml | 2 +- sop-example/sop-springmvc/pom.xml | 2 +- sop-example/sop-story/sop-story-web/pom.xml | 2 +- sop-gateway/pom.xml | 2 +- sop-website/pom.xml | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sop-auth/pom.xml b/sop-auth/pom.xml index d70d96f1..d5b56ffa 100644 --- a/sop-auth/pom.xml +++ b/sop-auth/pom.xml @@ -26,7 +26,7 @@ com.gitee.sop sop-service-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT diff --git a/sop-common/pom.xml b/sop-common/pom.xml index 96e55498..89c70b7d 100644 --- a/sop-common/pom.xml +++ b/sop-common/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.gitee.sop sop-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT pom diff --git a/sop-common/sop-bridge-gateway/pom.xml b/sop-common/sop-bridge-gateway/pom.xml index 4cfc4cf4..078a0d9c 100644 --- a/sop-common/sop-bridge-gateway/pom.xml +++ b/sop-common/sop-bridge-gateway/pom.xml @@ -5,11 +5,11 @@ sop-common com.gitee.sop - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT ../pom.xml 4.0.0 - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT sop-bridge-gateway @@ -17,7 +17,7 @@ com.gitee.sop sop-gateway-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT diff --git a/sop-common/sop-bridge-zuul/pom.xml b/sop-common/sop-bridge-zuul/pom.xml index 3f55c6f0..4787ab59 100644 --- a/sop-common/sop-bridge-zuul/pom.xml +++ b/sop-common/sop-bridge-zuul/pom.xml @@ -5,11 +5,11 @@ sop-common com.gitee.sop - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT ../pom.xml 4.0.0 - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT sop-bridge-zuul @@ -17,7 +17,7 @@ com.gitee.sop sop-gateway-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT diff --git a/sop-common/sop-gateway-common/pom.xml b/sop-common/sop-gateway-common/pom.xml index 5ce5de36..5a1e11ca 100644 --- a/sop-common/sop-gateway-common/pom.xml +++ b/sop-common/sop-gateway-common/pom.xml @@ -5,11 +5,11 @@ com.gitee.sop sop-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT ../pom.xml sop-gateway-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT jar sop-gateway-common diff --git a/sop-common/sop-service-common/pom.xml b/sop-common/sop-service-common/pom.xml index a1bf36f7..7f6343dd 100644 --- a/sop-common/sop-service-common/pom.xml +++ b/sop-common/sop-service-common/pom.xml @@ -6,11 +6,11 @@ com.gitee.sop sop-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT ../pom.xml sop-service-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT jar sop-service-common diff --git a/sop-example/sop-book/sop-book-web/pom.xml b/sop-example/sop-book/sop-book-web/pom.xml index bba92b3d..57a9ed0a 100644 --- a/sop-example/sop-book/sop-book-web/pom.xml +++ b/sop-example/sop-book/sop-book-web/pom.xml @@ -28,7 +28,7 @@ com.gitee.sop sop-service-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT com.gitee.sop diff --git a/sop-example/sop-easyopen/pom.xml b/sop-example/sop-easyopen/pom.xml index f3b00d0c..e9ef1f8d 100644 --- a/sop-example/sop-easyopen/pom.xml +++ b/sop-example/sop-easyopen/pom.xml @@ -29,7 +29,7 @@ com.gitee.sop sop-service-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT diff --git a/sop-example/sop-story/sop-story-web/pom.xml b/sop-example/sop-story/sop-story-web/pom.xml index 7db75c50..286d149d 100644 --- a/sop-example/sop-story/sop-story-web/pom.xml +++ b/sop-example/sop-story/sop-story-web/pom.xml @@ -28,7 +28,7 @@ com.gitee.sop sop-service-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT com.gitee.sop diff --git a/sop-gateway/pom.xml b/sop-gateway/pom.xml index e6d09ed2..e3595ace 100644 --- a/sop-gateway/pom.xml +++ b/sop-gateway/pom.xml @@ -34,7 +34,7 @@ com.gitee.sop sop-bridge-gateway - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT diff --git a/sop-website/pom.xml b/sop-website/pom.xml index b961f3f3..883372af 100644 --- a/sop-website/pom.xml +++ b/sop-website/pom.xml @@ -35,7 +35,7 @@ com.gitee.sop sop-gateway-common - 3.1.0-SNAPSHOT + 3.1.1-SNAPSHOT