davsclaus commented on code in PR #26921:
URL: https://github.com/apache/camel/pull/26921#discussion_r4114649229
##########
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:
This suggests the flow form `myBean: {type: ...}`, which the deserializer
accepts, but `BeanRefChecks.MAP_KEY_PATTERN` only matches a key line ending in
`:`. So `declaredBeans` does not see the bean, a `ref: myBean` /
`${bean:myBean}` is reported as undeclared, and `camel_write_file` refuses the
file. Maybe write the hint in block form (`myBean:` then `type: ...` indented
under it), which matches the docs example?
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/BeanRefChecks.java:
##########
@@ -55,25 +56,85 @@ private BeanRefChecks() {
static final Pattern BEAN_TYPE_PATTERN =
Pattern.compile("^\\s*type:\\s*[\"']?#class:([\\w.$]+)");
- /** The beans declared under {@code beans:} with a {@code #class:} type,
name to fully qualified class name. */
+ /** A bean written as a map: the name alone as the key, its properties
indented below (CAMEL-24704). */
+ static final Pattern MAP_KEY_PATTERN =
Pattern.compile("^(\"[^\"]+\"|'[^']+'|[^\\s:#\"'][^:#]*?):\\s*$");
Review Comment:
Alternatively (or as well), this could recognize a flow-mapping bean at the
child indent (`myBean: {type: "#class:..."}`) so the reference and type checks
match what the deserializer accepts. A test with the flow form would cover 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]