847850277 commented on code in PR #4270:
URL: https://github.com/apache/shenyu/pull/4270#discussion_r1056906679
##########
shenyu-client/shenyu-client-dubbo/shenyu-client-alibaba-dubbo/src/main/java/org/apache/shenyu/client/alibaba/dubbo/AlibabaDubboServiceBeanListener.java:
##########
@@ -60,6 +69,44 @@ public AlibabaDubboServiceBeanListener(final
PropertiesConfig clientConfig,
super(clientConfig, shenyuClientRegisterRepository);
}
+ @Override
+ protected List<ApiDocRegisterDTO> buildApiDocDTO(final Class<?> clazz,
final Method method) {
+ final String contextPath = getContextPath();
+ String apiDesc =
Stream.of(method.getDeclaredAnnotations()).filter(item -> item instanceof
ApiDoc).findAny().map(item -> {
+ ApiDoc apiDoc = (ApiDoc) item;
+ return apiDoc.desc();
+ }).orElse("");
+ String superPath = buildApiSuperPath(clazz,
AnnotatedElementUtils.findMergedAnnotation(clazz, getAnnotationType()));
+ if (superPath.indexOf("*") > 0) {
+ superPath = superPath.substring(0, superPath.lastIndexOf("/"));
+ }
+ ShenyuDubboClient shenyuDubboClient =
AnnotatedElementUtils.findMergedAnnotation(method, ShenyuDubboClient.class);
+ if (Objects.isNull(shenyuDubboClient)) {
+ return Lists.newArrayList();
+ }
+ List<ApiDocRegisterDTO> list = Lists.newArrayList();
+ String value = shenyuDubboClient.value();
+ String apiPath = contextPath + superPath + value;
+ ApiDocRegisterDTO build = ApiDocRegisterDTO.builder()
+ .consume(ShenyuClientConstants.MEDIA_TYPE_ALL_VALUE)
+ .produce(ShenyuClientConstants.MEDIA_TYPE_ALL_VALUE)
+ .httpMethod(ApiHttpMethodEnum.NOT_HTTP.getValue())
+ .contextPath(contextPath)
+ .ext("{}")
+ .document("{}")
+ .version("v0.01")
Review Comment:
i try this code,but it didn't work
```java
if (apiModuleClass.isAnnotationPresent(Service.class)) {
Service dubboService = apiModuleClass.getAnnotation(Service.class);
apiVersion = dubboService.version();
} else {
DubboService dubboService =
apiModuleClass.getAnnotation(DubboService.class);
apiVersion = dubboService.version();
}
```
##########
shenyu-client/shenyu-client-dubbo/shenyu-client-alibaba-dubbo/src/main/java/org/apache/shenyu/client/alibaba/dubbo/AlibabaDubboServiceBeanListener.java:
##########
@@ -60,6 +69,44 @@ public AlibabaDubboServiceBeanListener(final
PropertiesConfig clientConfig,
super(clientConfig, shenyuClientRegisterRepository);
}
+ @Override
+ protected List<ApiDocRegisterDTO> buildApiDocDTO(final Class<?> clazz,
final Method method) {
+ final String contextPath = getContextPath();
+ String apiDesc =
Stream.of(method.getDeclaredAnnotations()).filter(item -> item instanceof
ApiDoc).findAny().map(item -> {
+ ApiDoc apiDoc = (ApiDoc) item;
+ return apiDoc.desc();
+ }).orElse("");
+ String superPath = buildApiSuperPath(clazz,
AnnotatedElementUtils.findMergedAnnotation(clazz, getAnnotationType()));
+ if (superPath.indexOf("*") > 0) {
+ superPath = superPath.substring(0, superPath.lastIndexOf("/"));
+ }
+ ShenyuDubboClient shenyuDubboClient =
AnnotatedElementUtils.findMergedAnnotation(method, ShenyuDubboClient.class);
+ if (Objects.isNull(shenyuDubboClient)) {
+ return Lists.newArrayList();
+ }
+ List<ApiDocRegisterDTO> list = Lists.newArrayList();
+ String value = shenyuDubboClient.value();
+ String apiPath = contextPath + superPath + value;
+ ApiDocRegisterDTO build = ApiDocRegisterDTO.builder()
+ .consume(ShenyuClientConstants.MEDIA_TYPE_ALL_VALUE)
+ .produce(ShenyuClientConstants.MEDIA_TYPE_ALL_VALUE)
+ .httpMethod(ApiHttpMethodEnum.NOT_HTTP.getValue())
+ .contextPath(contextPath)
+ .ext("{}")
+ .document("{}")
+ .version("v0.01")
+ .rpcType(RpcTypeEnum.DUBBO.getName())
+ .apiDesc(apiDesc)
+ .apiPath(apiPath)
+ .apiSource(1)
+ .state(1)
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]