[BUG] issue with Spring required args constructor
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
After this change https://github.com/OpenAPITools/openapi-generator/pull/14822 now when adding <additionalModelTypeAnnotations>@lombok.experimental.SuperBuilder</additionalModelTypeAnnotations>
compilation might be broken
If object have some required parameters then everything works fine, but as soon as you have object without required parameters you are getting model where only "all args constructor" is present(generated by lombok) and there is no "no arg constructor"
Before this change I usually configured my models with <additionalModelTypeAnnotations>@lombok.AllArgsConstructor;@lombok.NoArgsConstructor;@lombok.experimental.SuperBuilder</additionalModelTypeAnnotations>
so at the end I got "all args" & "no args" constructor generated by lombok
openapi-generator version
6.5.0-SNAPSHOT (not released yet)
OpenAPI declaration file content or url
any model with at least one property and there are no required properties
Generation Details
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.5.0-SNAPSHOT</version>
<configuration>
<generateSupportingFiles>true</generateSupportingFiles>
<modelNameSuffix>Dto</modelNameSuffix>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<generateApiDocumentation>false</generateApiDocumentation>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<dateLibrary>java8</dateLibrary>
<useTags>true</useTags>
<openApiNullable>false</openApiNullable>
<skipDefaultInterface>true</skipDefaultInterface>
<documentationProvider>springfox</documentationProvider>
</configOptions>
</configuration>
<executions>
<execution>
<id>generate-openapi-for-backend</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/contract/_index_auto.yaml</inputSpec>
<generatorName>spring</generatorName>
<configOptions>
<additionalModelTypeAnnotations>@lombok.AllArgsConstructor;@lombok.NoArgsConstructor;@lombok.experimental.SuperBuilder</additionalModelTypeAnnotations>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/14822
Suggest a fix
add option generatedRequiredParametersConstructor=false
. By default it should be false, because this new option will broke compilation as it's in my case
@alucas could you please implement this? Please ping if you have no time, then I can pick this one