Open jjoslet opened 4 years ago
This is working as expected I am afraid. If the source code of DataSourceProperties
is not available, we can't extract the documentation and default value as the annotation processor doesn't have access to the source model.
However, I can see how that's annoying and how the doc example is misleading. Flagging for team attention.
Since this is an annotation processor, this is hard to retrieve the JavaDoc from a compiled class.
I think this pattern can have a different behavior for the computation of the default value too.
Have you planned another way to produce the description which does not suffer from this limitation ?
Maybe another annotation that is used to describe the property ?
@jjoslet I think I wrote exactly that in my previous comment, didn't I? We haven't scheduled anything at this point but I'd like to discuss it a bit more which is why I've flagged it.
We may be able to find the existing metadata that was generated for DataSourceProperties
from the classpath and splice it into the metadata that is being generated.
That will solve the issue for the particular DataSourceProperties
example since it already produces meta-data. But it'll not handle the case where a third party class is not originally annotated with @ConfigurationProperties
and is used in an application with @ConfigurationProperties
.
Example in Spring Boot: HikariDataSource
, org.apache.tomcat.jdbc.pool.DataSource
. org.apache.commons.dbcp2.BasicDataSource
, etc.
We have metadata for that too. Ssl
is more what you meant and we'll have to figure out how we can update the annotation processor to handle it. I think the issue is well understood, we now need to design it.
Yes, metadata are present but they miss the description.
spring-configuration-metadata.json
from spring-boot-autoconfigure-2.1.8.RELEASE.jar
:
{
"name": "spring.datasource.dbcp2.username",
"type": "java.lang.String",
"sourceType": "org.apache.commons.dbcp2.BasicDataSource"
}
It's a third party type, they don't have description as it's not a @ConfigurationProperties
type to begin with.
Since #19500 is closed: My use-case is not to generate metadata for external 3rd-party classes outside my control. I am the maintainer of the jar providing the @ConfigurationProperty
type and would cooperate in providing the required metadata - for example by using annotations instead of JavaDoc or by means of manually publishing the required metadata within my jar.
I got that. Generating the metadata and reusing it is covered here too.
Spring Boot version: 2.1.8.RELEASE
When using a class imported from a dependency as a
@ConfigurationProperties
, the generated configuration properties meta-data does not contains the description for this class' properties.Scenario to reproduce: I test the example described in the documentation to create two data sources : https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html#howto-two-datasources.
The produced
spring-configuration-metadata.json
does not include the description for the properties ofDataSourceProperties
class.Here is a sample of the produced meta-data:
Sample project: demo.zip