davsclaus commented on code in PR #29099:
URL: https://github.com/apache/camel/pull/29099#discussion_r4457549879


##########
tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java:
##########
@@ -594,13 +594,70 @@ private List<String> 
getSignatures(List<ApiMethodParser.ApiMethodModel> models,
         for (ApiMethodParser.ApiMethodModel model : models) {
             if (model.getName().equals(methodName)) {
                 if (model.getSignature() != null) {
-                    list.add(model.getSignature());
+                    
list.add(getSignatureWithArgumentNames(model.getSignature(), 
model.getArguments()));
                 }
             }
         }
         return list;
     }
 
+    /**
+     * Returns the signature with the argument names of the given arguments, 
so the signature shows the names after
+     * substitution, as those are the names the endpoint expects (such as with 
inBody).
+     *
+     * @param  signature the method signature as parsed from the source, with 
the original argument names
+     * @param  arguments the method arguments (after substitution) in the 
order of the signature
+     * @return           the signature with the argument names replaced, or 
the signature as-is if the arguments do not
+     *                   match the signature
+     */
+    static String getSignatureWithArgumentNames(String signature, 
List<ApiMethodArg> arguments) {
+        final int start = signature.indexOf('(');
+        final int end = signature.lastIndexOf(')');
+        if (start == -1 || end < start) {
+            return signature;
+        }
+
+        // find the start and end of each argument name, the last identifier 
before a top level comma (not inside generics)
+        final List<int[]> names = new ArrayList<>();
+        int depth = 0;
+        int segmentStart = start + 1;
+        for (int i = start + 1; i <= end; i++) {
+            char ch = signature.charAt(i);
+            if (ch == '<') {
+                depth++;
+            } else if (ch == '>') {
+                depth--;
+            } else if (i == end || ch == ',' && depth == 0) {

Review Comment:
   Done in ab5d53f86b27.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_



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

Reply via email to