CAMEL-23863: Fix invalid YAML in rest-api jbang example and add example-loading test#24340
Conversation
…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>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
💡 Manual integration tests recommended:
All tested modules (7 modules)
|
|
you need to fix this in camel-jbang-examples as these in core project are copied over from there via a maven sync profile. |
|
PR description updated with link to apache/camel-jbang-examples fix. |
…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>
Description
Fixes CAMEL-23863.
Running
camel run --example=rest-apifailed at startup:Root cause: the bundled
rest-api.camel.yamlplaced asteps:key underrest:and defined verbs without ato:target.stepsis not a valid property of the REST DSL<rest>element; verbs (get/post/put/delete) must be direct children ofrest, each a list whose entries carry ato: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 therestnode.Changes:
dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/rest-api/rest-api.camel.yamlso the verbs are children ofrestwithto:targets routingGET /api/helloandGET /api/hello/{name}todirect:hello/direct:hello-name(the two routes the example already defines).ExampleRoutesLoadTest, a parameterized test that loads every bundled example undercamel-jbang-corethrough the routes loader, guarding all examples against this class of regression. Acamel.example.Greetertest fixture mirrors the runtime-compiled bean so theroutes/beans.yamlexample 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-catalogMaven 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
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.AI-assisted contributions
Co-authored-bytrailers) 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