ammachado opened a new pull request, #26921:
URL: https://github.com/apache/camel/pull/26921

   # Description
   
   [CAMEL-24704](https://issues.apache.org/jira/browse/CAMEL-24704): `beans` 
written keyed by the bean name now fails with the list form to write, at 
runtime as well as in the validator. The list stays the only form of `beans:`.
   
   This PR first accepted the map form next to the list, as the JIRA proposed. 
Following the review, it now takes the other option: keep one form (the list) 
and steer people and AI models to it through the error messages, so docs, the 
writer, the schemas and Kaoto stay on a single style. The map-form 
implementation is kept on a local branch in case the project later decides to 
switch fully to the map form (that would be a dev list decision).
   
   The two shapes people and models write first:
   
   ```yaml
   - beans:
       myProcessor:                 # a map keyed by the bean name
         type: "#class:com.example.MyProcessor"
   ```
   
   ```yaml
   - beans:
       - myProcessor:               # a list item keyed by the bean name
           type: "#class:com.example.MyProcessor"
   ```
   
   `camel validate` already explained how to rewrite both, but `camel run` 
failed with `Node type map is invalid, expected array` or `Unsupported field: 
myProcessor`.
   
   **Runtime** (`camel-yaml-dsl-deserializers`)
   - `BeansDeserializer.checkBeansIsAList(Node)` is called for the top-level 
`beans`, and for the `beans` of `routeTemplate` and `templatedRoute`.
   - A map: `beans is a list: each bean starts with "- ": - name: myProcessor 
followed by type: "#class:com.example.MyBean" (indented under the -)`. When the 
first key is `name:` (the `- ` of the list item was forgotten), the hint uses 
its value.
   - An item with a single key holding a map, other than the bean's own map 
properties (`properties`, `constructors`): `a bean item is written as - name: 
myProcessor followed by type: ... (the name is a property, not the key)`.
   - These are the validator's existing hints, so `camel run` and `camel 
validate` now say the same thing.
   
   **Validator** (`camel-yaml-dsl-validator`)
   - The two bean item hints (an item keyed by name, and `id`/`ref`/`class` 
instead of `name`/`type`) matched `/\d+/beans/\d+` in full, so only the 
top-level beans got them. They now match `.*/beans/\d+`, like the existing map 
hint (`.*/beans`), which also covers `routeTemplate` and `templatedRoute`.
   
   No schema, doc or upgrade-guide change: what is accepted is unchanged, only 
the messages are.
   
   **Tests**: `BeansTest` covers the map, the forgotten `- `, an item keyed by 
name, a `routeTemplate` map and a `templatedRoute` keyed item, plus a guard 
that a lone `properties:` item still reports the missing name. 
`YamlValidatorPropertyHintTest` covers the template hints. Against `main`'s 
code, 5 of the 6 new `BeansTest` tests and the new validator test fail (the 
guard passes by design). With this change: camel-yaml-dsl-validator 262/262, 
and `BeansTest`, `RouteTemplateTest`, `TemplatedRouteTest` 41/41.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [x] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
   
   The root build passed (run with `mvnd`). The change adds no generated 
content, and the build left no uncommitted changes from this PR. It did 
regenerate `model.properties` with a `wasm` entry, which came from untracked 
`src/generated` files left in my worktree from before CAMEL-25677 removed the 
wasm language. I deleted those local files and did not commit anything for it.
   
   # AI-assisted contributions
   
   - [x] 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.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code) on behalf of 
Adriano Machado (@ammachado)
   
   _This was generated by an AI agent and may contain inaccuracies. Please 
verify before relying on it._
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to