Skip to content

Harvest property descriptions from a @ConfigurationProperties-annotated record #28074

@wilkinsona

Description

@wilkinsona

At the moment, the configuration properties annotation processor harvests property descriptions from a class's fields. This doesn't work well with records as they don't have fields. It'd be nice if we could devise some other way of harvesting property descriptions from the record's source. At the moment, you have to use additional metadata instead.

One possibility may be to read the @params from the record-level javadoc:

/**
 * @param someProperty An example property to be described in the metadata.
 */
@ConfigurationProperties(prefix = "record")
public record MyRecordProperties(String someProperty) { }

In this example, we already generate metadata for someProperty:

{
  "name": "record.some-property",
  "type": "java.lang.String",
  "sourceType": "com.example.recordconfigpropstest.MyRecordProperties"
}

What we're aiming for is having a description as well:

{
  "name": "record.some-property",
  "type": "java.lang.String",
  "description": "An example property to be described in the metadata.",
  "sourceType": "com.example.recordconfigpropstest.MyRecordProperties"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions