CAMEL-24004: Generated REST DSL always emits type on param definitions#24602
Conversation
The XML model writer skips attributes matching their default value, so type="path" (the default for ParamDefinition) was omitted from the generated XML. The YAML and XML generators now ensure the type attribute is always present in the output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet
left a comment
There was a problem hiding this comment.
Claude Code review on behalf of @gnodet
LGTM — clean, well-scoped fix.
Analysis
Root cause is correct: ParamDefinition.type defaults to RestParamType.path (line 53 of ParamDefinition.java), and ModelWriter.doWriteAttribute() skips attributes matching their default value. So type="path" was silently dropped from the intermediate XML representation, causing both the YAML and XML generators to omit it from output.
Fix approach is sound: Post-processing in the generators is the right level for this fix. The model writer's default-omitting behavior is by design (keeps serialized form concise); the generators are the ones that need the complete attribute set.
YAML generator refactoring is a nice cleanup — extracting ObjectNode on = (ObjectNode) pc to the top of the loop eliminates three redundant casts while adding the type fix.
Test coverage is comprehensive: 7 resource files updated (5 YAML, 2 XML) covering all 48 path parameter entries across Petstore and Greetings specs.
Note
PR #24599 added a workaround in RestTest.groovy that skips schema validation for generated REST DSL (loadRoutes([rdsl], false) with comment referencing CAMEL-24004). Once this PR merges, that skip should be reverted to re-enable validation — the root cause is now fixed.
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 10 tested, 11 compile-only — current: 10 all testedMaveniverse Scalpel detected 21 affected modules (current approach: 10).
|
|
The CAMEL-24004 workaround in |
Summary
typefield on<param>definitions, even when the value is the defaultpathModelWriter.doWriteAttribute) which skips attributes matching their default value — sotype="path"was silently dropped from the intermediate XML, causing the generated YAML/XML to omit itfixParamNodes()now addstype: "path"when missing, and the XML generator adds a similar post-processing step on the DOMTest plan
openapi-rest-dsl-generatorpass with updated expected outputscamel-yaml-dslRestTest "load rest (generated)" now passes with schema validation enabled (previously needed validation skip workaround)type: "path"for all 48 path parameter entriesClaude Code on behalf of davsclaus
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com