This is an automated email from the ASF dual-hosted git repository.
Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new b0cd6fe43f fix: update rpcExt property key to lowercase and add
related test cases (#6912)
b0cd6fe43f is described below
commit b0cd6fe43f80354a1fcfbfc194da04112858cb65
Author: Limbo <[email protected]>
AuthorDate: Fri Aug 14 17:08:31 2026 +0800
fix: update rpcExt property key to lowercase and add related test cases
(#6912)
Co-authored-by: aias00 <[email protected]>
---
.../registrar/AbstractApiDocRegistrar.java | 2 +-
.../register/registrar/ApiDocRegistrarImpl.java | 2 +-
.../registrar/ApiDocRegistrarImplTest.java | 25 ++++++++++++++++++++++
.../registrar/NoHttpApiDocRegistrarTest.java | 21 ++++++++++++++++++
4 files changed, 48 insertions(+), 2 deletions(-)
diff --git
a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrar.java
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrar.java
index 30ddb88286..5ad43647a3 100644
---
a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrar.java
+++
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrar.java
@@ -137,7 +137,7 @@ public abstract class AbstractApiDocRegistrar extends
AbstractApiRegistrar<ApiDo
ext.setServiceName(apiDefinition.getApiBean().getBeanClass().getName());
ext.setMethodName(apiDefinition.getApiMethodName());
ext.setParameterTypes(apiDefinition.getParameterTypes());
- ext.setRpcExt(apiDefinition.getPropertiesValue("RpcExt"));
+ ext.setRpcExt(apiDefinition.getPropertiesValue("rpcExt"));
ext.setAddPrefixed(addPrefixed);
if (rpcTypeEnum == RpcTypeEnum.HTTP) {
diff --git
a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImpl.java
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImpl.java
index 10d07877a4..b4bd04ca9b 100644
---
a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImpl.java
+++
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImpl.java
@@ -110,7 +110,7 @@ public class ApiDocRegistrarImpl extends
BaseApiRegistrarImpl {
apiExt.setServiceName(api.getApiBean().getBeanClass().getName());
apiExt.setMethodName(api.getApiMethodName());
apiExt.setParameterTypes(api.getParameterTypes());
- apiExt.setRpcExt(api.getPropertiesValue("RpcExt"));
+ apiExt.setRpcExt(api.getPropertiesValue("rpcExt"));
apiExt.setAddPrefixed(clientRegisterConfig.getAddPrefixed());
final String rpcType = getRpcType(api);
diff --git
a/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImplTest.java
b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImplTest.java
index d3b3857de0..31a024d5ae 100644
---
a/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImplTest.java
+++
b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImplTest.java
@@ -123,6 +123,24 @@ public class ApiDocRegistrarImplTest {
assertThat(docMap.get("operationId"), is("/custom"));
}
+ @Test
+ void testGetExtWithRpcExt() throws Exception {
+ ApiBean apiBean = new ApiBean(RpcTypeEnum.DUBBO.getName(),
+ TestDubboService.class.getName(),
+ TestDubboService.class.getDeclaredConstructor().newInstance(),
+ "dubboTestService");
+
+ apiBean.addApiDefinition(TestDubboService.class.getMethod("findById",
String.class), "/findById");
+ ApiBean.ApiDefinition apiDefinition =
apiBean.getApiDefinitions().get(0);
+ String rpcExt = "{\"group\":\"test-group\",\"version\":\"1.0.0\"}";
+ apiDefinition.addProperties("rpcExt", rpcExt);
+
+ String ext = invokeGetExt(dubboRegistrar, apiDefinition);
+
+ Map<String, Object> extMap = GsonUtils.getInstance().toObjectMap(ext);
+ assertThat(extMap.get("rpcExt"), is(rpcExt));
+ }
+
@SuppressWarnings("unchecked")
private String invokeGetDocument(final ApiDocRegistrarImpl registrar,
final ApiBean.ApiDefinition api) throws Exception {
Method getDocumentMethod =
ApiDocRegistrarImpl.class.getDeclaredMethod("getDocument",
ApiBean.ApiDefinition.class);
@@ -130,6 +148,13 @@ public class ApiDocRegistrarImplTest {
return (String) getDocumentMethod.invoke(registrar, api);
}
+ @SuppressWarnings("unchecked")
+ private String invokeGetExt(final ApiDocRegistrarImpl registrar, final
ApiBean.ApiDefinition api) throws Exception {
+ Method getExtMethod =
ApiDocRegistrarImpl.class.getDeclaredMethod("getExt",
ApiBean.ApiDefinition.class);
+ getExtMethod.setAccessible(true);
+ return (String) getExtMethod.invoke(registrar, api);
+ }
+
// --- Inner types (must be after all methods per checkstyle
InnerTypeLast) ---
public static class TestDubboService {
diff --git
a/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrarTest.java
b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrarTest.java
index e9760c6dc9..47e3bd63ea 100644
---
a/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrarTest.java
+++
b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrarTest.java
@@ -25,12 +25,15 @@ import org.apache.shenyu.client.core.register.ApiBean;
import org.apache.shenyu.client.core.register.ClientRegisterConfig;
import org.apache.shenyu.common.enums.ApiHttpMethodEnum;
import org.apache.shenyu.common.enums.RpcTypeEnum;
+import org.apache.shenyu.common.utils.GsonUtils;
import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository;
import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO;
import org.apache.shenyu.register.common.type.DataTypeParent;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import java.util.Map;
+
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
@@ -130,6 +133,24 @@ public class NoHttpApiDocRegistrarTest {
dto.getDocument().contains("\"responseParameters\""),
is(true));
}
+ @Test
+ public void testRpcExtInExtJson() throws Exception {
+ ApiBean apiBean = new ApiBean(RpcTypeEnum.DUBBO.getName(),
+ DubboTestServiceImpl.class.getName(),
+
DubboTestServiceImpl.class.getDeclaredConstructor().newInstance(),
+ "dubboTestService");
+
+
apiBean.addApiDefinition(DubboTestServiceImpl.class.getMethod("findById",
String.class), "/findById");
+ ApiBean.ApiDefinition apiDefinition =
apiBean.getApiDefinitions().get(0);
+ String rpcExt = "{\"group\":\"test-group\",\"version\":\"1.0.0\"}";
+ apiDefinition.addProperties("rpcExt", rpcExt);
+
+ noHttpApiDocRegistrar.register(apiBean);
+
+ Map<String, Object> extMap =
GsonUtils.getInstance().toObjectMap(testPublisher.metaData.getExt());
+ assertThat(extMap.get("rpcExt"), is(rpcExt));
+ }
+
@Test
public void testGrpcDocumentGenerationWithParameters() throws Exception {
ApiBean apiBean = new ApiBean(RpcTypeEnum.GRPC.getName(),