gnodet-bot commented on code in PR #28021:
URL: https://github.com/apache/camel/pull/28021#discussion_r4303076349


##########
dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/DocBlocks.java:
##########
@@ -57,14 +62,52 @@ public static List<String> examples(String doc) {
         }
         Matcher m = YAML_BLOCK.matcher(doc);
         while (m.find()) {
-            String yaml = 
CALLOUT.matcher(m.group(1)).replaceAll("").stripTrailing() + "\n";
-            if (yaml.stripLeading().startsWith("- ") && !markedToSkip(doc, 
m.start())) {
+            String yaml = 
CALLOUT.matcher(m.group(2)).replaceAll("").stripTrailing() + "\n";
+            if (startsWithEntry(yaml) && !markedToSkip(doc, m.start())) {
                 answer.add(yaml);
             }
         }
         return answer;
     }
 
+    /** The entries a YAML DSL file is a list of. */
+    private static final Set<String> TOP_LEVEL = Set.of("beans", 
"dataFormats", "errorHandler", "from", "intercept",
+            "interceptFrom", "interceptSendToEndpoint", "kamelet", 
"onCompletion", "onException", "rest",
+            "restConfiguration", "route", "route-configuration", 
"route-template", "routeConfiguration", "routeTemplate",
+            "sslContextParameters", "templated-route", "templatedRoute", 
"transformers", "validators");

Review Comment:
   ⚠️ **Bug:** `kamelet` is not a top-level schema root — it's a processor step 
under `ProcessorDefinition.properties` in `camelYamlDsl.json`. Including it 
here would incorrectly accept a `- kamelet:` step fragment as a route file when 
it follows a comment.
   
   Meanwhile, `semantic` _is_ a top-level root (listed in `camelYamlDsl.json`'s 
`items.properties`) but is absent from this set.
   
   ```suggestion
       private static final Set<String> TOP_LEVEL = Set.of("beans", 
"dataFormats", "errorHandler", "from", "intercept",
               "interceptFrom", "interceptSendToEndpoint", "onCompletion", 
"onException", "rest",
               "restConfiguration", "route", "route-configuration", 
"route-template", "routeConfiguration", "routeTemplate",
               "semantic", "sslContextParameters", "templated-route", 
"templatedRoute", "transformers", "validators");
   ```



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