Skip to content

CAMEL-23863: Fix invalid YAML in rest-api jbang example and add example-loading test#24340

Merged
davsclaus merged 2 commits into
apache:mainfrom
ammachado:CAMEL-23863
Jul 1, 2026
Merged

CAMEL-23863: Fix invalid YAML in rest-api jbang example and add example-loading test#24340
davsclaus merged 2 commits into
apache:mainfrom
ammachado:CAMEL-23863

Conversation

@ammachado

@ammachado ammachado commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes CAMEL-23863.

Running camel run --example=rest-api failed at startup:

ERROR ... org.apache.camel.main.MainSupport : Error starting Camel:
Error constructing YAML node id: rest
 in file:.../rest-api.camel.yaml, line 2, column 5:
        path: /api
        ^

Root cause: the bundled rest-api.camel.yaml placed a steps: key under rest: and defined verbs without a to: target. steps is not a valid property of the REST DSL <rest> element; verbs (get/post/put/delete) must be direct children of rest, each a list whose entries carry a to: target. The failure happens during route-model construction (not pure YAML parsing), which is why the reported position points at the first child line of the rest node.

Changes:

  • Correct the verb structure in dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/rest-api/rest-api.camel.yaml so the verbs are children of rest with to: targets routing GET /api/hello and GET /api/hello/{name} to direct:hello / direct:hello-name (the two routes the example already defines).
  • Add ExampleRoutesLoadTest, a parameterized test that loads every bundled example under camel-jbang-core through the routes loader, guarding all examples against this class of regression. A camel.example.Greeter test fixture mirrors the runtime-compiled bean so the routes/beans.yaml example parses.

Verified the test fails on the pre-fix file with the original Error constructing YAML node id: rest, and passes after the fix (14 example cases).

Upstream source: these bundled examples are synced from apache/camel-jbang-examples via the sync-example-catalog Maven profile. The same fix has been submitted upstream in apache/camel-jbang-examples#68 so the next catalog sync does not re-introduce the broken file.

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

AI-assisted contributions

  • If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., Co-authored-by trailers) and the PR description identifies the AI tool used.

Authored with Claude Code (Opus 4.8) on behalf of Adriano Machado.

🤖 Generated with Claude Code

…le-loading test

The bundled rest-api example placed a `steps:` key under `rest:` with no `to:`
targets. That is not valid REST DSL: verbs (get/post/put/delete) must be direct
children of `rest`, each carrying a `to:` target. As a result `camel run
--example=rest-api` failed during route-model construction with "Error
constructing YAML node id: rest".

Correct the verbs to be direct children of `rest`, routing GET /api/hello and
GET /api/hello/{name} to direct:hello / direct:hello-name (the two routes the
example already defines).

Add ExampleRoutesLoadTest, a parameterized test that loads every bundled example
under camel-jbang-core through the routes loader, guarding all examples against
this class of regression. A camel.example.Greeter test fixture mirrors the
runtime-compiled bean so the routes/beans.yaml example can be parsed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.

@github-actions github-actions Bot added the dsl label Jun 30, 2026
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-core

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-core: 1 test(s) disabled on GitHub Actions

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-jbang-core. The related integration tests in dsl/camel-jbang/camel-jbang-it are excluded from CI. Consider running them manually:

mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
All tested modules (7 modules)
  • Camel :: JBang :: Core
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container

⚙️ View full build and test results

@davsclaus

Copy link
Copy Markdown
Contributor

you need to fix this in camel-jbang-examples as these in core project are copied over from there via a maven sync profile.

@ammachado

Copy link
Copy Markdown
Contributor Author

PR description updated with link to apache/camel-jbang-examples fix.

@ammachado
ammachado marked this pull request as ready for review June 30, 2026 20:37
…discovery

Address review feedback on the example-loading test:

- Replace the `beans:` substring heuristic with a model-aware check that
  also counts REST definitions, route templates and registered beans, so
  a tolerated-but-empty example fails and a REST/template-only example
  does not spuriously fail.
- Resolve the examples from the classpath instead of a CWD-relative path,
  so the test runs identically under Surefire and IDEs; use a relativized
  display name for each parameterized case.
- Correct the javadoc: example beans are instantiated during pre-parse
  (only endpoint wiring is deferred to context start), and document the
  Greeter fixture sync requirement.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@davsclaus
davsclaus merged commit 24b83a6 into apache:main Jul 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants