I was trying to migrate my project to spring boot 3 and thus updated lombok to version v1.18.32.
We are trying to generate model classes using open-api-generator plugin and with this new version of lombok, it is expected to use @Builder.default on fields with default value assigned. But unfortunately this annotations is not getting generated at all and I am getting below warning:
*** @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. If it is not supposed to be settable during building, make the field final.***
I want to get this of this warning. Can anyone help me understand on how do we add builder.default annotations while model generation using open-api-generator plugin.
Config in pom.xml :
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.3.0</version>
<executions>
<execution>
<id>execution-test-api-spec</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<configOptions>
<additionalModelTypeAnnotations>@com.fasterxml.jackson.annotation.JsonIgnoreProperties(ignoreUnknown =
false)
@lombok.NoArgsConstructor
@lombok.AllArgsConstructor
@lombok.Builder
@com.fasterxml.jackson.annotation.JsonInclude
(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)
@lombok.Builder.Default
</additionalModelTypeAnnotations>
</configOptions>
</configuration>
</execution>`
```
- **Current Output:**
```
public class TestDto {
@JsonProperty("Example")
private List<Object> example = new ArrayList<>();
}
```
- **Expected Output:**
```
public class TestDto {
@JsonProperty("Example")
**@Builder.Default**
private List<Object> example = new ArrayList<>();
}
```