You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by GitBox <gi...@apache.org> on 2022/12/25 06:23:01 UTC

[GitHub] [shenyu] 847850277 commented on a diff in pull request #4270: [ISSUE #4029] add shenyu-client-api-doc part1 client module

847850277 commented on code in PR #4270:
URL: https://github.com/apache/shenyu/pull/4270#discussion_r1056906390


##########
shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java:
##########
@@ -108,7 +112,24 @@ public void onApplicationEvent(@NonNull final ContextRefreshedEvent event) {
         }
         publisher.publishEvent(buildURIRegisterDTO(context, beans));
         beans.forEach(this::handle);
+        Map<String, Object> apiModules = context.getBeansWithAnnotation(ApiModule.class);
+        apiModules.forEach(this::handleApiDoc);
     }
+
+    private void handleApiDoc(final String name, final Object classes) {

Review Comment:
   fixed



##########
shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java:
##########
@@ -108,7 +112,24 @@ public void onApplicationEvent(@NonNull final ContextRefreshedEvent event) {
         }
         publisher.publishEvent(buildURIRegisterDTO(context, beans));
         beans.forEach(this::handle);
+        Map<String, Object> apiModules = context.getBeansWithAnnotation(ApiModule.class);
+        apiModules.forEach(this::handleApiDoc);
     }
+
+    private void handleApiDoc(final String name, final Object classes) {
+        Class<?> apiModuleClass = AopUtils.isAopProxy(classes) ? AopUtils.getTargetClass(classes) : classes.getClass();
+        final Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(apiModuleClass);
+        for (Method method : methods) {
+            if (method.isAnnotationPresent(ApiDoc.class)) {
+                List<ApiDocRegisterDTO> apis = buildApiDocDTO(apiModuleClass, method);
+                for (ApiDocRegisterDTO apiDocRegisterDTO : apis) {
+                    publisher.publishEvent(apiDocRegisterDTO);
+                }
+            }
+        }
+    }
+
+    protected abstract List<ApiDocRegisterDTO> buildApiDocDTO(Class<?> clazz, Method method);

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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org