[ 
https://issues.apache.org/jira/browse/CAMEL-24361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen reassigned CAMEL-24361:
-----------------------------------

    Assignee: Claus Ibsen

> 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
>            Assignee: 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)

Reply via email to