Skip to content

CAMEL-24004: Generated REST DSL always emits type on param definitions#24602

Merged
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24004
Jul 11, 2026
Merged

CAMEL-24004: Generated REST DSL always emits type on param definitions#24602
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24004

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Summary

  • Fix the OpenAPI REST DSL generators (YAML and XML) to always emit the type field on <param> definitions, even when the value is the default path
  • The root cause was in the XML model writer (ModelWriter.doWriteAttribute) which skips attributes matching their default value — so type="path" was silently dropped from the intermediate XML, causing the generated YAML/XML to omit it
  • The YAML generator's fixParamNodes() now adds type: "path" when missing, and the XML generator adds a similar post-processing step on the DOM

Test plan

  • All 13 existing tests in openapi-rest-dsl-generator pass with updated expected outputs
  • camel-yaml-dsl RestTest "load rest (generated)" now passes with schema validation enabled (previously needed validation skip workaround)
  • Updated 7 test resource files (5 YAML, 2 XML) to include type: "path" for all 48 path parameter entries

Claude Code on behalf of davsclaus

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

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>
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • tooling/openapi-rest-dsl-generator

🔬 Scalpel shadow comparison — Scalpel: 10 tested, 11 compile-only — current: 10 all tested

Maveniverse Scalpel detected 21 affected modules (current approach: 10).

⚠️ Modules only in Scalpel (11)
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-yaml-dsl
  • coverage

Skip-tests mode would test 10 modules (1 direct + 9 downstream), skip tests for 11 (generated code, meta-modules)

Modules Scalpel would test (10)
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-openapi-rest-dsl-generator
  • camel-restdsl-openapi-plugin
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (11)
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-yaml-dsl
  • coverage

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (21 modules)
  • Camel :: Coverage
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: Maven Plugins :: OpenApi REST DSL Generator
  • Camel :: Tooling :: OpenApi REST DSL Generator
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@davsclaus davsclaus added this to the 4.22.0 milestone Jul 11, 2026
@davsclaus davsclaus self-assigned this Jul 11, 2026
@davsclaus davsclaus added the bug Something isn't working label Jul 11, 2026
@davsclaus davsclaus merged commit d99ff4e into main Jul 11, 2026
5 checks passed
@davsclaus davsclaus deleted the fix/CAMEL-24004 branch July 11, 2026 17:33
@davsclaus

Copy link
Copy Markdown
Contributor Author

The CAMEL-24004 workaround in RestTest.groovy (added by PR #24599) has been reverted on main — schema validation is now re-enabled for the generated REST DSL test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants