davsclaus opened a new pull request, #27254: URL: https://github.com/apache/camel/pull/27254
[CAMEL-25255](https://issues.apache.org/jira/browse/CAMEL-25255) The model writers had gaps: the route DSL converter (CAMEL-25254) found them when it read its output back. The YAML they wrote for rests and route templates did not load in the YAML DSL, and this also broke `camel transform route --format=yaml` and `camel.main.dumpRoutes=yaml`. The Java writer also left parts of some routes out. ## YAML writer (camel-yaml-io) The fix is in the generator template (`model-yaml-writer.vm`), so it survives regeneration: - **Rest verbs** are listed by their kind (`get:`, `post:`, ...) instead of under `verbs:`. Within a verb, `params` becomes `param` and `responseMsgs` becomes `responseMessage`. An allowable value is now `value:` instead of `expression:`. - **Route templates** have `parameters` / `beans` instead of `templateParameter` / `templateBean`. - **Bean properties and constructors** are a map, including nested properties (`nested: {p1: v1a}`), instead of a `property:` list. The top-level `- beans:` dump now uses the same writer, so nested properties are no longer written as `{p1=v1a, ...}`. ## Java writer (camel-java-io) - **A route's own error handler** is written as `.errorHandler(...)` on the route, not as an `errorHandler(...)` of the RouteBuilder. In a file with two routes, the RouteBuilder-level form applied the last route's error handler to both routes. - `RouteDefinition.errorHandler(ErrorHandlerFactory)` now also keeps the error handler in the model, as a copy of its definition. The Java DSL builders are model definitions, but the generated writers don't know the builder subclasses. Before this change, XML, YAML and Java dumps of a Java route dropped its own error handler. - **XPath / XQuery / xtokenize namespaces** are written as `.namespaces(Map.of(...))`, which the Java parser reads back. Before, `expression().xpath("/t:ticket")` was written without the `t` prefix. - **Languages with a builder method** (groovy, ognl, mvel, js, ...) are written as `expression().groovy("...").end()`, so they read back as their own expression, not `language("groovy", ...)`. - **`ResequenceDefinition.timeout(long)`** stores the millis as given (`2000`), not `2s0ms`. Not changed, by design: - Route-scoped `intercept`, `interceptFrom` and `interceptSendToEndpoint` stay at RouteBuilder level, because Java has no route-scoped form. - The YAML DSL has no route-scoped form for them either. - `interceptFrom` and the steps after a kamelet were already listed as known in `YamlRoundTripTest`. ## Tests - **`YamlRestTemplateRoundTripTest`** (new): rests and route templates go from XML to YAML, through the YAML DSL loader, and must come back as the same model. The rest covers all six verbs, params with examples and allowable values, response messages with headers, security definitions and requirements, and openApi. - **`YamlBeansDumpTest`** (new): nested bean properties. - **`RoundTripTest.xmlCorpusReadsBackThroughJava`** (new): the camel-xml-io/camel-core route corpus goes from XML to Java to the parser and back to XML, and must match. - The result is 155 of 160 routes; it was 141 before this PR. - The 5 routes listed as known are the route-scoped intercepts, the DLC `logExhausted` default, and Resilience4j's `30.0`. - Fixtures updated to the corrected output: `yaml-rest.yaml`, `yaml-route-template.yaml`, `yaml-beans*.yaml`, `blueprint-out.yaml`. `JavaDslCompileTest` imports `java.util.Map`. - Run locally, all green: - camel-yaml-io, camel-java-io, camel-xml-io, and the camel-yaml-dsl-validator suite; - the jbang `Transform*Test` and MCP `TransformToolsTest`; - camel-main `*Dump*`; - camel-core `*Resequence*`, `*ErrorHandler*`, `*DeadLetter*`, `*Dump*` and `*Saga*` (456 tests). The upgrade guide for 4.23 has a note about the changed dump output. _Claude Code on behalf of davsclaus_ 🤖 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]
