fjtirado commented on code in PR #4178:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4178#discussion_r2759813586


##########
quarkus/addons/asyncapi/deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/asyncapi/AsyncAPIInfoConverter.java:
##########
@@ -48,19 +51,57 @@ public Optional<AsyncInfo> apply(String id) {
 
     private static AsyncInfo from(AsyncAPI asyncApi) {
         Map<String, AsyncChannelInfo> map = new HashMap<>();
-        for (Entry<String, ChannelItem> entry : 
asyncApi.getChannels().entrySet()) {
-            addChannel(map, entry.getValue().getPublish(), entry.getKey() + 
"_out", true);
-            addChannel(map, entry.getValue().getSubscribe(), entry.getKey(), 
false);
+
+        // AsyncAPI v3.0.0 migration: In v3, channels and operations are 
separate top-level objects
+        // v2: channels contained publish/subscribe operations directly
+        // v3: operations reference channels via $ref, and channels have 
addresses
+        // Build a helper map: channelId -> address (topic/path)
+        Map<String, String> channelIdToAddress = new HashMap<>();
+        if (asyncApi.getChannels() != null) {
+            for (Entry<String, Object> ch : asyncApi.getChannels().entrySet()) 
{
+                String channelId = ch.getKey();
+                if (ch.getValue() instanceof Channel) {
+                    Channel channel = (Channel) ch.getValue();
+                    // In v3, address holds the actual path/topic (key is just 
an ID)
+                    String address = 
Optional.ofNullable(channel.getAddress()).orElse(channelId);
+                    channelIdToAddress.put(channelId, address);
+                }
+            }
         }
-        return new AsyncInfo(map);
-    }
 
-    private static void addChannel(Map<String, AsyncChannelInfo> map, 
Operation operation, String channelName, boolean publish) {
-        if (operation != null) {
-            String operationId = operation.getOperationId();
-            if (operationId != null) {
-                map.putIfAbsent(operationId, new AsyncChannelInfo(channelName, 
publish));
+        // Iterate operations and map operation key -> AsyncChannelInfo
+        if (asyncApi.getOperations() != null) {
+            for (Entry<String, Object> opEntry : 
asyncApi.getOperations().entrySet()) {
+                String opKey = opEntry.getKey();
+                if (!(opEntry.getValue() instanceof Operation)) {
+                    continue;
+                }
+                Operation op = (Operation) opEntry.getValue();

Review Comment:
   and then you nest the code



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to