The spring boot auto-configuration via metadata (eg application.properties) can be improved to have a better camelCaseToDash algorithm.
For example at Apache Camel we have a JMS component that has many options, one of them is:
private Boolean includeAllJMSXProperties = false;
https://github.com/apache/camel/blob/master/platforms/spring-boot/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java#L506
Which gets generated as camel-jms-starter Spring Boot JAR with this option name:
We then grab all these SB option names and include them in the online documentation at: https://github.com/apache/camel/blob/master/components/camel-jms/src/main/docs/jms-component.adoc#spring-boot-auto-configuration
Where you can see the option in the table listed as
camel.component.jms.configuration.include-all-j-m-s-x-properties
Notice how JMSX gets transformed to -j-m-s-x- which is a bit ugly, instead it would be nicer if it was -jmsx-
So it would be nicer if the algorithm was improved to output the name as:
camel.component.jms.configuration.include-all-jmsx-properties
Which we have done in our Camel Main (standalone Camel without Spring Boot) https://github.com/apache/camel/blob/master/examples/camel-example-main-artemis/src/main/resources/META-INF/spring-configuration-metadata.json#L950
We are using this algorithm to do this: https://github.com/apache/camel/blob/master/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java#L825
Which works with this unit test:
@Test
public void testCamelCashToDash() throws Exception {
assertEquals("hello-world", camelCaseToDash("HelloWorld"));
assertEquals("hello-big-world", camelCaseToDash("HelloBigWorld"));
assertEquals("hello-big-world", camelCaseToDash("Hello-bigWorld"));
assertEquals("my-id", camelCaseToDash("MyId"));
assertEquals("my-id", camelCaseToDash("MyID"));
assertEquals("my-url", camelCaseToDash("MyUrl"));
assertEquals("my-url", camelCaseToDash("MyURL"));
assertEquals("my-big-id", camelCaseToDash("MyBigId"));
assertEquals("my-big-id", camelCaseToDash("MyBigID"));
assertEquals("my-big-url", camelCaseToDash("MyBigUrl"));
assertEquals("my-big-url", camelCaseToDash("MyBigURL"));
assertEquals("my-big-id-again", camelCaseToDash("MyBigIdAgain"));
assertEquals("my-big-id-again", camelCaseToDash("MyBigIDAgain"));
assertEquals("my-big-url-again", camelCaseToDash("MyBigUrlAgain"));
assertEquals("my-big-url-again", camelCaseToDash("MyBigURLAgain"));
assertEquals("use-mdc-logging", camelCaseToDash("UseMDCLogging"));
}
https://github.com/apache/camel/blob/master/core/camel-util/src/test/java/org/apache/camel/util/StringHelperTest.java
PS: I am not sure if there is any logic that would need to be changed as well to support mapping with this new algorithm.
Comment From: mbhave
Related issue and commit which contains history about why this was done this way.
Comment From: philwebb
We might be able to revisit #5330 in 2.x since we've rewritten the binder.
Comment From: mbhave
The binder supports this so we should do something so that the metadata generates include-all-jmsx-properties
Comment From: wilkinsona
Excellent. Thanks, @mbhave.
I wonder what effect a change in the metadata will have on backwards compatibility. For example, if someone has include-all-j-m-s-x-properties in their .properties or .yml file how will their IDE behave when they upgrade to a version with the new metadata. I think it'd be nice if it didn't start complaining that they were using a non-existent property. It'd be nicer still if it could guide them towards using include-all-jmsx-properties instead.
Comment From: snicoll
We can imagine generating an additional deprecated entry with a replacement that points to the new format. This can be removed in a future release.
Comment From: philwebb
We're cleaning out the issue tracker and closing issues that we've not seen much demand to fix. Feel free to comment with additional justifications if you feel that this one should not have been closed.