[
https://issues.apache.org/jira/browse/CAMEL-24361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-24361:
--------------------------------
Description:
The EIP model JSON metadata has lost the {{required}} flag for several options
since 4.21.0.
h3. Root cause
Commit {{5d0de099703c}} (CAMEL-23816) added {{@Metadata(description = "...")}}
annotations to many fields in camel-core-model. However, {{findRequired()}} in
{{SchemaGeneratorMojo}} checks for {{@Metadata}} and if present, uses its
{{required}} attribute (which defaults to {{false}}). This overrides the
{{@XmlAttribute(required = true)}} that was previously being picked up
correctly.
Before CAMEL-23816:
- {{SetHeaderDefinition.name}} had {{@XmlAttribute(required = true)}} and no
{{@Metadata}} → {{required = true}} in JSON
- {{LogDefinition.message}} had {{@XmlAttribute(required = true)}} and no
{{@Metadata}} → {{required = true}} in JSON
After CAMEL-23816:
- {{SetHeaderDefinition.name}} now has {{@Metadata(description = "...")}}
(without {{required = true}}) → {{findRequired()}} returns {{false}},
overriding {{@XmlAttribute(required = true)}}
The index ordering also flipped (name went from index 4 to 5, expression from 5
to 4).
h3. Fix options
*Option A:* Change {{findRequired()}} so that when {{@Metadata}} is present but
{{required}} is not explicitly set (still default {{false}}), it falls through
to the {{@XmlAttribute(required)}} value instead of overriding it.
*Option B:* Add {{required = true}} to all affected {{@Metadata}} annotations.
This is error-prone since the required flag is already declared on
{{@XmlAttribute}}.
Option A is the better fix.
h3. Affected EIPs (non-exhaustive)
All fields that have both {{@XmlAttribute(required = true)}} and a newly-added
{{@Metadata(description)}} without {{required = true}}: {{setHeader.name}},
{{log.message}}, {{setVariable.name}}, {{removeVariable.name}},
{{convertHeaderTo.name}}, {{convertHeaderTo.type}}, {{process.ref}},
{{setExchangePattern.pattern}}, {{interceptSendToEndpoint.uri}}, and others.
h3. Impact
Tooling that uses the catalog metadata (e.g. TUI source editor, MCP server) no
longer shows these options as required, making it harder for users to know
which fields they must fill in.
was:
The EIP model JSON metadata generator does not propagate the {{required}} flag
from {{@XmlAttribute(required = true)}} annotations in the Java model classes.
This causes the generated JSON model files to have {{"required": false}} for
options that are actually required.
For example:
- {{SetHeaderDefinition.name}} has {{@XmlAttribute(required = true)}} but
{{setHeader.json}} has {{"required": false}} for {{name}}
- {{LogDefinition.message}} has {{@XmlAttribute(required = true)}} but
{{log.json}} has {{"required": false}} for {{message}}
- Many other EIPs are affected: {{setVariable}}, {{removeVariable}},
{{convertHeaderTo}}, {{process}}, {{setExchangePattern}},
{{interceptSendToEndpoint}}, etc.
This impacts tooling that uses the catalog metadata to indicate required
options to users (e.g. the TUI source editor tab completion popup shows
required options in bold at the top of the list).
The fix should be in the {{camel-package-maven-plugin}} model generation to
read the {{@XmlAttribute(required)}} annotation and set the {{required}} field
accordingly in the generated JSON.
> EIP model metadata does not propagate @XmlAttribute(required = true) to
> generated JSON
> --------------------------------------------------------------------------------------
>
> Key: CAMEL-24361
> URL: https://issues.apache.org/jira/browse/CAMEL-24361
> Project: Camel
> Issue Type: Bug
> Components: tooling
> Reporter: Claus Ibsen
> Priority: Minor
>
> The EIP model JSON metadata has lost the {{required}} flag for several
> options since 4.21.0.
> h3. Root cause
> Commit {{5d0de099703c}} (CAMEL-23816) added {{@Metadata(description =
> "...")}} annotations to many fields in camel-core-model. However,
> {{findRequired()}} in {{SchemaGeneratorMojo}} checks for {{@Metadata}} and if
> present, uses its {{required}} attribute (which defaults to {{false}}). This
> overrides the {{@XmlAttribute(required = true)}} that was previously being
> picked up correctly.
> Before CAMEL-23816:
> - {{SetHeaderDefinition.name}} had {{@XmlAttribute(required = true)}} and no
> {{@Metadata}} → {{required = true}} in JSON
> - {{LogDefinition.message}} had {{@XmlAttribute(required = true)}} and no
> {{@Metadata}} → {{required = true}} in JSON
> After CAMEL-23816:
> - {{SetHeaderDefinition.name}} now has {{@Metadata(description = "...")}}
> (without {{required = true}}) → {{findRequired()}} returns {{false}},
> overriding {{@XmlAttribute(required = true)}}
> The index ordering also flipped (name went from index 4 to 5, expression from
> 5 to 4).
> h3. Fix options
> *Option A:* Change {{findRequired()}} so that when {{@Metadata}} is present
> but {{required}} is not explicitly set (still default {{false}}), it falls
> through to the {{@XmlAttribute(required)}} value instead of overriding it.
> *Option B:* Add {{required = true}} to all affected {{@Metadata}}
> annotations. This is error-prone since the required flag is already declared
> on {{@XmlAttribute}}.
> Option A is the better fix.
> h3. Affected EIPs (non-exhaustive)
> All fields that have both {{@XmlAttribute(required = true)}} and a
> newly-added {{@Metadata(description)}} without {{required = true}}:
> {{setHeader.name}}, {{log.message}}, {{setVariable.name}},
> {{removeVariable.name}}, {{convertHeaderTo.name}}, {{convertHeaderTo.type}},
> {{process.ref}}, {{setExchangePattern.pattern}},
> {{interceptSendToEndpoint.uri}}, and others.
> h3. Impact
> Tooling that uses the catalog metadata (e.g. TUI source editor, MCP server)
> no longer shows these options as required, making it harder for users to know
> which fields they must fill in.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)