davsclaus opened a new pull request, #30581: URL: https://github.com/apache/camel/pull/30581
JIRA: [CAMEL-27362](https://issues.apache.org/jira/browse/CAMEL-27362) ### What was wrong The YAML DSL turns every key under `parameters:` into camelCase (`StringHelper.dashToCamelCase`), so an option can be written in dash form (`bridge-endpoint`). That also changed the keys of a map option (multiValue), which Camel passes on to the library as written: ```yaml - to: uri: cxf://http://localhost:8080/orders parameters: properties.ws-security.username: alice properties.security.callback-handler: "#myHandler" ``` became `properties.wsSecurity.username` and `properties.security.callbackHandler`, which CXF ignores. The keys of a map value (`properties: {ws-security.username: alice}`) were changed too (`asMap` camelCases nested keys). Kamelet templates use the YAML DSL, so they hit it as well. The same bug affects servicenow, whose prefixes `request-model.` and `response-model.` have a dash themselves. ### The fix - The endpoint parameters are now parsed with the keys as written (`YamlDeserializerSupport.asEndpointParameters`, used by `parseParameters`, `YamlDeserializerEndpointAwareBase` and `asEndpoint`). `asMap` / `asScalarMap` are not changed, so other callers (such as the Kamelet EIP parameters) work as before. - `YamlSupport.createEndpointUri` turns the option names into camelCase using the component's `EndpointUriFactory.multiValuePrefixes()`. If a key starts with a prefix, only the prefix is camelCased and the rest of the key is kept as written. It uses the longest prefix, because ftp has nested prefixes (`ftpClient.` and `ftpClient.keyStore.`). The prefix can be written as is or in dash form (`ftp-client.`). Keys of a map value are kept as written. - With no factory for the scheme, the whole key is camelCased as before. **Why the exact multiValue prefix and not "only up to the first dot":** the factory is already looked up at this point, to put secrets in RAW and to flatten map options, so the exact prefixes are available. A rule like "up to the first dot" would be wrong for a nested prefix such as `ftpClient.keyStore.`. It would also stop camelCasing dotted keys that are not map entries. When the factory does not know the prefix, the key keeps today's behaviour. **History:** the repo is shallow at this point (the boundary commit 53112be4 owns the line), so `git blame` does not reach the commit that added the `dashToCamelCase`. It is deliberate (it comes from the Camel K YAML loader, so options can be written in dash form), and this PR keeps it for option names. **No regression for map options that are bean properties** (such as `scheduler.`): `PropertyBindingSupport` undashes the property name when it binds, so `scheduler.pool-size` still sets `poolSize` on the scheduler. A test checks this. ### Tests - New `YamlSupportOptionNameTest` (camel-yaml-dsl-common): option names in dash form, keys after a prefix, a prefix in dash form, a prefix with a dash (`request-model.`), the longest of nested prefixes, no prefixes (camelCased as before). 6 tests, pass. - New `ParametersMultiValueTest` (camel-yaml-dsl, uses the file component's `scheduler.` prefix): prefixed keys, a map value under `scheduler-properties`, a dotted key that is not a prefix (camelCased as before), the uri as scheme only, a consumer whose `scheduler.pool-size` reaches the scheduler bean. Without the fix, 4 of the 5 fail (for example `scheduler.myOption=hello` instead of `scheduler.my-option=hello`). With the fix, all 5 pass. - Full `camel-yaml-dsl` test suite with the changed common module: 527 tests, 0 failures, 0 errors. The CXF case was not run end-to-end, because camel-cxf is not a test dependency of the YAML DSL module. Its factory has the prefix `properties.` (the same code path as `scheduler.`). ### Docs `yaml-dsl.adoc` has a new section, "Option names in dash form", with the CXF example. The catalog copy is updated as well. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
