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

   JIRA: https://issues.apache.org/jira/browse/CAMEL-25494
   
   ## Problem
   
   The YAML route dump (`camel.main.dumpRoutes=yaml`, used by `camel validate 
normalize`) writes the `onException` items of a `routeConfiguration` without 
their `onException:` key:
   
   ```yaml
   - routeConfiguration:
       id: myConfig
       onException:
         - exception:
             - java.lang.Exception
           ...
   ```
   
   `camel validate yaml` rejects it (`property 'exception' is not defined in 
the schema`), and `camel run` fails with `Node should have only have 1 key, 
was: 3 keys`. The `onCompletion`, `intercept`, `interceptFrom` and 
`interceptSendToEndpoint` lists of a route configuration have the same problem.
   
   ## Cause
   
   The YAML DSL reads each item of these five lists as a one-key map named 
after the list (`wrapItem = true` in 
`RouteConfigurationDefinitionDeserializer`), but the generated 
`YamlModelWriter` writes them as lists of bare objects, as the XML DSL has 
them. The existing writer test (`yaml-routeconfig.yaml`) expected the wrong 
form.
   
   ## Fix
   
   - `model-yaml-writer.vm` (camel-package-maven-plugin) lists these members, 
as it already does for the YAML DSL names of other lists, and generates 
`doWriteWrappedChildList` for them. The new helper in `YamlModelWriterSupport` 
writes each item as `- onException: ...`. `YamlModelWriter` is regenerated; 
only the five lines of `doWriteRouteConfigurationDefinition` change.
   - Once the route configuration loaded back, a second problem showed up: with 
`uriAsParameters` (as `camel validate normalize` dumps), the uri pattern of 
`interceptSendToEndpoint` (such as `mock:result*`) was split into `uri: mock` 
and `parameters: {name: result*}`, which the schema of 
`interceptSendToEndpoint` and `interceptFrom` does not allow (and a pattern is 
not an endpoint uri). `LwModelToYAMLDumper` now writes the uri of these two 
interceptors as it is; the steps inside them are still written with parameters.
   
   ## Test
   
   - `YamlModelWriterTest.testRouteConfiguration` (camel-yaml-io) covers all 
five lists, with the expected `yaml-routeconfig.yaml` changed to the form the 
YAML DSL loads.
   - `RouteConfigurationYamlDumpTest` (camel-yaml-dsl) loads a route 
configuration with all five lists, dumps it as `camel.main.dumpRoutes` does, 
and loads the dump back with the JSON schema validation of `YamlTestSupport`.
   
   The camel-yaml-io and camel-yaml-dsl tests pass.
   
   ## Related
   
   Split out of CAMEL-25490 (#27609). Independent of it: #27609 changes how 
routes are dumped, this changes how route configurations are written. The fix 
applies to camel-4.22.x as well; a backport will follow once this is merged.
   
   _Claude Code on behalf of Croway_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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