-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[BUG][JavaSpring] wrong parsing of space separated lombok annotations #18868
Comments
@gunnarkessler There is no such
To generate a no-arg-constructor, the spring generator needs to check the combination of
This is nearly impossible to achieve in straight mustache conditions. It seems your usage of lombok is to create a builder. |
Sorry, if I put it ambiguously. I was trying to say, that the above section was still present in 7.5.0. and removed with 7.6.0 Thank you for the pointer to I am currently performing a spring boot upgrade of an application consuming numerous extrenal REST-services and therefore also updating the generator used and a lot of external dependencies. Our application stack expects objects to be deserialized to have a default constructor. Before upgrading the generator all generated pojos contained no default constructor but the aforementioned lombok annotation, after the upgrade pojos for contract objects with required fields hat explicit default constructors generated, and objects without required fields had none. I was looking for a way to generate the pojos with the same structure as before the update. I had already stumbled upon |
@gunnarkessler The root cause of the bug is the parsing of ADDITIONAL_MODEL_TYPE_ANNOTATIONS and the subsequent parsing of lombok annotations The lombok annotion parsing is done with this regex: So the handling in postProcessAllModels() does not know about NoArgsConstructor. The fact that it worked in 7.5.0 and before is probably pure luck. Workaround for you: use semicolon separated values: Can you rename your bug report to reflect the finding? Like "wrong parsing of space separated lombok annotations" |
Thank you for the explanation and all the infos. I will look into the workaround. |
Bug Report Checklist
Description
Starting with Version 7.6.0 the lombok Annotation @NoArgsConstructor collides with a generated default constructor since the pojo.mustache for JavaSpring was changed with #18650 and the inverted Section
{{^lombok.NoArgsConstructor}}
surrounding the template for the default constructor was removed. The PR and the Release Notes seem to not contain any infos regarding this change, which led me to the hypothesis this change might have been unintentional.actual output: a pojo with a default constructor and the lombok annotation @NoArgsConstructor added that does not compile
expected output: a pojo with no default constructor and the lombok annotation @NoArgsConstructor added that does compile
openapi-generator version
7.6.0
OpenAPI declaration file content or url
Issue does not seem to be dependent on details of YAML
Generation Details
openapi-maven-generator-plugin version 7.6.0 was used to generate - relevant to the issue at hand is adding @lombok.NoArgsConstructor via
<additionalModelTypeAnnotations>
.Steps to reproduce
Use openapi-generator-maven-plugin in version 7.6.0 with the above to generate artifacts. The generated Pojo does not compile.
After downgrading the plugin to version 7.5.0 the problem is resolved. No default constructor is generated that collides with the Lombok-Annotation. The generated Pojo compiles.
Related issues/PRs
I checked all issues created since the release of version 7.6.0 and did not find any already adressing this problem.
Suggest a fix
Re-adding the removed inverted section
{{^lombok.NoArgsConstructor}}
around the template for the default constructor should resolve this issue.The text was updated successfully, but these errors were encountered: