davsclaus opened a new pull request, #25840:
URL: https://github.com/apache/camel/pull/25840

   ## Summary
   
   `camel validate yaml --canonical` on a route with a single `unmarshal` data 
format (e.g. `json`) incorrectly demands that all ~50 other data formats also 
be present, reporting dozens of `required property 'X' not found` errors.
   
   Root cause: the canonical YAML DSL JSON schema disables the `oneOf` grouping 
used to express "pick exactly one of N alternatives" 
(`GenerateYamlSchemaMojo`'s `isInOneOf` is always `false` in canonical mode). 
Each data-format alternative on `unmarshal` also carries `required = true` 
(needed to enforce "exactly one of N" in the classic, `oneOf`-based schema), 
and that flag leaked straight into the flat top-level `required` list once the 
`oneOf` grouping was dropped — turning "choose one of 50 formats" into "all 50 
are mandatory".
   
   While investigating, found `marshal.dataFormatType` was missing the same 
`required = true` annotation `unmarshal.dataFormatType` has, so it accidentally 
avoided this bug — but also silently accepted a `marshal` step with **no** data 
format at all, which fails at route-build time with `IllegalArgumentException: 
type must be specified`. Aligned `MarshalDefinition` with `UnmarshalDefinition` 
so both enforce the same "exactly one data format" contract, consistent with 
actual runtime behavior.
   
   Since a flat, `oneOf`-free canonical schema cannot itself express "exactly 
one of N" cardinality, `YamlValidator` now re-checks it directly, driven by the 
same `oneOf`/`required` metadata already published in the Camel catalog's EIP 
model JSON. This covers every "pick one" option group generically (data 
formats, expression languages, error handlers, load balancers, resequencer 
config, tokenizers) without hardcoding any of their alternative names.
   
   ## Changes
   
   - `GenerateYamlSchemaMojo`: don't add a `oneOf`-grouped property to the 
canonical schema's flat `required` list.
   - `MarshalDefinition`: mark `dataFormatType` as `required = true`, matching 
`UnmarshalDefinition` and actual runtime behavior.
   - `YamlValidator` (canonical mode only): loads "pick exactly one" option 
groups from the Camel catalog and re-validates that cardinality, since the 
canonical schema can no longer express it directly.
   - Regenerated YAML DSL schemas/deserializers/catalog model docs.
   - Updated `MarshalTest` (`marshal: {}` with no data format now correctly 
fails, matching `unmarshal`'s existing behavior) and extended 
`YamlCanonicalValidatorTest`.
   
   ## Test plan
   
   - [x] `mvn test` in `camel-yaml-dsl-validator`, `camel-yaml-dsl`, 
`camel-core-model`, `camel-yaml-dsl-maven-plugin`, `camel-catalog`
   - [x] Full root `mvn clean install -DskipTests` (mandatory sanity build) — 
no unexpected regen drift
   - [x] Manually reproduced the original bug with the local `camel` CLI 
(`camel validate yaml --canonical`) and confirmed the fix
   
   ---
   _Claude Code on behalf of @davsclaus_
   
   Co-Authored-By: Claude Sonnet 5 <[email protected]>


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