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


##########
dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/SchemaHints.java:
##########
@@ -263,6 +263,12 @@ static Error apply(List<Hint> table, Error error, 
YamlValidator validator) {
             append("type", ".*/beans", m -> m.message().contains("array 
expected"),
                     m -> "beans is a list: - name: myBean followed by type: 
\"#class:com.example.MyBean\" (indented"
                          + " under the -)"),
+            // beans:\n  name: myBean\n  type: ...: the "- " of the list form 
was forgotten; the map form's first
+            // key happens to be "name", read as a bean property rather than 
the map key (CAMEL-24704 F1)
+            append("type", ".*/beans/name", m -> m.message().contains("object 
expected"),
+                    m -> "beans is a list: each bean starts with \"- \": - 
name: myBean followed by type:"
+                         + " \"#class:com.example.MyBean\" (indented under the 
-); or a map keyed by the bean name:"
+                         + " myBean: {type: ...}"),

Review Comment:
   Hints should steer towards the canonical list form only, so I'd not 
advertise the map form (especially the flow style, which `BeanRefChecks` does 
not recognise):
   ```suggestion
                       m -> "beans is a list: each bean starts with \"- \": - 
name: myBean followed by type:"
                            + " \"#class:com.example.MyBean\" (indented under 
the -)"),
   ```



##########
dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/SchemaHints.java:
##########
@@ -291,8 +297,9 @@ static Error apply(List<Hint> table, Error error, 
YamlValidator validator) {
             append("required", ".*/route/from", m -> 
m.message().contains("required property 'steps' not found"),
                     m -> "steps: is a property of from:, next to uri:; a 
steps: written at the route level must be"
                          + " indented under from:"),
-            // - id: myBean / class: ... : the bean properties are name and 
type
-            unknownProperty("/\\d+/beans/\\d+", m -> Set.of("id", "ref", 
"class").contains(m.unknown()),
+            // - id: myBean / class: ... , or myBean: {class: ...} in the map 
form: the bean properties are name
+            // and type (CAMEL-24704 F3: the map form's item is keyed by name, 
not by an index)
+            unknownProperty("/\\d+/beans/[^/]+", m -> Set.of("id", "ref", 
"class").contains(m.unknown()),

Review Comment:
   Now that this also matches a map-form bean (`/beans/myBean`), the message 
"(name instead of class, type instead of class)" is misleading there, because 
the name is already the key. Could the "name instead of ..." part be emitted 
only when the last path segment is a numeric index? A test asserting the 
map-form message does not say "name instead of" would pin it.



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