[ 
https://issues.apache.org/jira/browse/CAMEL-24694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18114472#comment-18114472
 ] 

Claus Ibsen commented on CAMEL-24694:
-------------------------------------

Verified against networknt json-schema-validator 2.0.1 with the real 
camelYamlDsl.json (JBang check, 2026-09-11). The builder setter is 
{{SchemaRegistryConfig.builder().typeLoose(true)}} (defined on 
{{SchemaRegistryConfig.BuilderSupport}}); the flag is honoured in 
{{com.networknt.schema.utils.JsonNodeTypes}}.

||case||typeLoose=false||typeLoose=true||
|{{parallelProcessing: "true"}} (boolean attribute)|string found, boolean 
expected|OK|
|{{parallelProcessing: "yes please"}}|rejected|rejected (correct)|
|{{timePeriodMillis: 10000}} (string-typed attribute, javaType 
Duration)|integer found, string expected|integer found, string expected|
|{{parallelProcessing: "{{par}}"}} (placeholder)|string found, boolean 
expected|string found, boolean expected|

So {{typeLoose(true)}} handles quoted scalars that parse as the schema type, 
and only those (source: it converts string to integer/boolean/number via 
{{Strings.isInteger/isBoolean/isNumeric}}, never the reverse, and has no notion 
of placeholders).

Two cases remain and are best handled by post-filtering the error list in 
{{YamlValidator}} rather than by touching the schema:
# a type error whose instance value is a string containing a property 
placeholder ({{{{}}...{{}}}}): drop it (the runtime resolves it before 
conversion);
# a "string expected" error whose instance value is a plain number or boolean: 
drop it (the runtime converts any scalar to text).
Everything else stays strict (unknown properties, structure, enums, 
non-parsable strings like "yes please").

> YAML DSL validator rejects scalar values the runtime accepts (quoted 
> booleans/numbers and placeholders at typed attributes)
> ---------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24694
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24694
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-yaml-dsl
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Major
>
> h3. Problem
> The generated YAML DSL JSON schema ({{camelYamlDsl.json}}) types scalar 
> attributes from the model's {{@Metadata(javaType=...)}} rather than from the 
> Java field type. Most EIP attributes are declared as {{String}} in the model 
> precisely so that property placeholders ({{{{myValue}}}}) can be used, and 
> the YAML deserializer converts the text at runtime. The schema is therefore 
> stricter than the runtime, in both directions:
> * {{SplitDefinition.parallelProcessing}} and {{streaming}} are {{String}} 
> fields with {{javaType=java.lang.Boolean}}; the schema emits {{boolean}}, so 
> {{parallelProcessing: "true"}} is rejected ("string found, boolean expected") 
> although {{camel run}} starts the route.
> * {{ThrottleDefinition.timePeriodMillis}} is a {{String}} field with 
> {{javaType=java.time.Duration}}; the schema emits {{string}}, so 
> {{timePeriodMillis: 10000}} is rejected ("integer found, string expected") 
> although {{camel run}} starts the route.
> * {{RestConfigurationDefinition.port}} and resilience4j 
> {{waitDurationInOpenState}} behave the same way (integer rejected, string 
> required).
> h3. Why it matters
> Every consumer of the schema refuses input the runtime accepts: {{camel 
> validate yaml}}, the Camel TUI save-time validation and its 
> {{tui_write_file}} / {{tui_validate_source}} MCP tools, camel-jbang-mcp 
> {{camel_validate_yaml_dsl}}, IDE plugins and Kaoto. On 2026-09-11, 41 of the 
> 280 YAML examples in the EIP documentation failed validation for this reason 
> alone, and in an AI-assisted editing benchmark two of the four corrections a 
> frontier model needed, and a large share of a local model's refused writes, 
> were this exact class ("integer found, string expected" / "string found, 
> boolean expected").
> h3. Suggested fix (generator, not hand edits)
> In the schema generator, for any model attribute whose Java field type is 
> {{String}}, emit a type union that accepts the string form as well as the 
> natural scalar: {{"type": ["string", "boolean"]}}, {{["string", "integer"]}}, 
> {{["string", "number"]}}. Keep the natural scalar first so completion and 
> documentation still show the intended type. Since placeholders make every 
> such attribute a valid string at runtime, this only removes false rejections; 
> the runtime type converter still reports genuinely wrong values.
> Optionally normalise the doc examples to the natural scalar form (see the 
> companion samples issue), but the schema should accept both.
> h3. Reproducer
> {code}
> - route:
>     from:
>       uri: timer:tick?period=1000
>       steps:
>         - split:
>             parallelProcessing: "true"
>             tokenize: ","
>             steps:
>               - log: "${body}"
> {code}
> {{camel validate yaml}}: {{/0/route/from/steps/0/split/parallelProcessing: 
> string found, boolean expected}}. {{camel run}}: Routes startup (total:1).
> Related: CAMEL-24692 (simple validator placeholder bug).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to