Claus Ibsen created CAMEL-23596:
-----------------------------------

             Summary: camel-yaml-io - Replace hand-written YamlWriter with 
generated direct YAML writer
                 Key: CAMEL-23596
                 URL: https://issues.apache.org/jira/browse/CAMEL-23596
             Project: Camel
          Issue Type: Improvement
            Reporter: Claus Ibsen
             Fix For: 4.21.0


The YAML dump mechanism in camel-yaml-io uses a hand-written YamlWriter (600 
lines) with 43+ hardcoded element names and special cases. Every new EIP that 
has configuration children (like circuitBreaker + resilience4jConfiguration) or 
introduces a new container type (like rests) silently produces wrong YAML until 
someone manually adds another special case.

The root cause: the generated ModelWriter emits a flat 
startElement/attribute/endElement stream (designed for XML), and YamlWriter 
must re-classify every child element at runtime to decide if it is a step, a 
configuration property, an expression, or a structural child. This 
classification is entirely hardcoded.

Proposal: Replace the hand-written YamlWriter + EipNode + Jackson pipeline with 
a generated direct writer that builds JsonObject/JsonArray structures and a 
small hand-written YamlPrinter that serializes them to YAML text. No Jackson 
dependency needed.

Current pipeline (6 conversions):
Model -> Generated ModelWriter -> YamlWriter.startElement/endElement -> 
EipModel metadata -> EipNode -> JsonObject -> JSON String -> Jackson 
ObjectMapper -> JsonNode -> Jackson YAMLMapper -> YAML String -> post-process 
(strip indent)

New pipeline (2 conversions):
Model -> Generated YamlModelWriter -> JsonObject/JsonArray -> YamlPrinter -> 
YAML String

Benefits:
- No more hardcoded special cases that break when new EIPs are added
- Classification of config children vs steps vs expressions happens at 
code-generation time
- Removes jackson-dataformat-yaml dependency from camel-yaml-io
- Simpler pipeline with full control over YAML output format
- Automatically correct when the model changes (new options, new EIPs)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to