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


##########
dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/YamlValidator.java:
##########
@@ -134,6 +134,27 @@ public List<Error> validate(String content) throws 
Exception {
         return validate(content, Set.of());
     }
 
+    /**
+     * The 1-based line of the YAML content a validation error points at (the 
line of the key of a property that is not
+     * allowed), or 0 when it has no location or the content does not parse.
+     */

Review Comment:
   Fixed in 772a8f696b8b: the Javadoc is back on `lineOf()`, the method it 
documents.
   
   _Claude Code on behalf of davsclaus_



##########
dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/YamlValidator.java:
##########
@@ -134,6 +134,27 @@ public List<Error> validate(String content) throws 
Exception {
         return validate(content, Set.of());
     }
 
+    /**
+     * The 1-based line of the YAML content a validation error points at (the 
line of the key of a property that is not
+     * allowed), or 0 when it has no location or the content does not parse.
+     */
+    /**
+     * A validation error as reports print it, with the line of the YAML 
content it points at in front when that is
+     * known: "Line 12: /0/route/from/steps/0/log: property 'logLevel' is not 
defined in the schema...".
+     */
+    public static String describe(String content, Error error) {
+        int line = content != null ? lineOf(content, error) : 0;
+        return line > 0 ? "Line " + line + ": " + error : 
String.valueOf(error);
+    }
+
+    public static int lineOf(String content, Error error) {
+        if (error == null || error.getInstanceLocation() == null) {
+            return 0;
+        }
+        return YamlPointerLines.line(YamlPointerLines.root(content), 
error.getInstanceLocation().toString(),
+                error.getMessage());
+    }

Review Comment:
   Fixed in 772a8f696b8b: `describeAll(content, errors)` parses the YAML once 
for all the errors of a file, and `camel validate yaml` and the Maven plugin 
use it. The single-error `describe()` is gone, as nothing else used it; 
`lineOf(content, error)` stays for one error and points at `describeAll` in its 
Javadoc.
   
   _Claude Code on behalf of 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