Comments (4)
Thank you for the explanation and all the infos. I will look into the workaround.
from openapi-generator.
@gunnarkessler There is no such {{^lombok.NoArgsConstructor}
in pojo.mustache in version 7.6.0. Do you use another version or do you have custom templates?
{{^lombok.NoArgsConstructor}
was removed in favor of a more robust {{#vendorExtensions.x-java-no-args-constructor}}
computed in java in SpringCodeGen.postProcessAllModels(Map<String, ModelsMap> objs)
To generate a no-arg-constructor, the spring generator needs to check the combination of
- fields present
- required fields present with generatedConstructorWithRequiredArgs=true
- required fields present with generatedConstructorWithRequiredArgs=false (maybe not done in 7.6.0. I will check)
- additionalProperties in the contract
- generateConstructorWithAllArgs flag
- generatedConstructorWithRequiredArgs
- lombok dedicated handling introduced in templates #17622
- additionalModelTypeAnnotations option with different combination of lombok annotations
This is nearly impossible to achieve in straight mustache conditions.
It seems your usage of lombok is to create a builder.
For that purpose you can use the new generateBuilders option and remove your additionalModelTypeAnnotations
from openapi-generator.
There is no such {{^lombok.NoArgsConstructor} in pojo.mustache in version 7.6.0. Do you use another version or do you have custom templates?
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 SpringCodeGen.postProcessAllModels(Map<String, ModelsMap> objs)
. I was only looking at the mustache-template.
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 vendorExtensions.x-java-no-args-constructor
but I have not yet understood, how and where to use this option.
from openapi-generator.
@gunnarkessler The root cause of the bug is the parsing of ADDITIONAL_MODEL_TYPE_ANNOTATIONS and the subsequent parsing of lombok annotations
The parsing of ADDITIONAL_MODEL_TYPE_ANNOTATIONS is done with a split using this regex
"\\s*(;|\\r?\\n)\\s*"
This code exists for years, so I would not consider that as an issue.
You use space instead of semi column in your configuration. So the result is additionalModelTypeAnnotations with one row.
The lombok annotion parsing is done with this regex:
"@lombok.(\\w+\\.)*(?<ClassName>\\w+)(\\(.*?\\))?"
The result is that lombokAnnotations contains only one row: @lombok.Builder
This is an additional bug introduced by the lombok handling. See #17793 for similar issues.
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:
@lombok.Builder;@lombok.NoArgsConstructor;@lombok.AllArgsConstructor
Can you rename your bug report to reflect the finding? Like "wrong parsing of space separated lombok annotations"
from openapi-generator.
Related Issues (20)
- [BUG][JAVA] APIClient.mustache template for apache-httplient library unnecessarily verifies if method allows request body HOT 1
- [BUG][kotlin] enums in form-urlencoded bodies generate non-nullable access compile error
- [BUG][RUST] oneOf with value and array results in invalid code
- [BUG][typescript-fetch] A request body of type `Set` fails at runtime
- [REQ][Java][Server][Spring] Add support for enumPropertyNaming config option in spring server generator HOT 2
- [REQ] Feature Request support jaxrs-spec generation with Quarkus
- Disable appending `def` to generated class names after upgrading from 5.30 -> 7.6.0 HOT 3
- [BUG][Typescript] Invalid oneOf strategy in models HOT 1
- [BUG] [python] Python client expects vulnerable urllib3 HOT 5
- [BUG][MAVEN] Bug generating .Net Client with Maven 7.6.0 Generator
- [BUG] python generated models for py3.11+ should use StrEnum instead of str,Enum HOT 3
- [BUG] Kotlin ApiClient leaks `okhttp3.Response`.
- [BUG][typescript-axios] Schema with `oneOf` is processed incorrectly
- [REQ] Support for a bearer token supplier for Java RestTemplate clients HOT 1
- [REQ] [Typescript] Specify "files" property in package.json
- [BUG] [Java] Mapped types should no be be validated by default
- [BUG][JAVA][SPRING] No downwards compability (spring 6 to spring 5) of pregenerated client because of new introduced HttpStatusCode HOT 1
- [BUG][Java][jaxrs-spec] When using discriminator, enum properties of children are defined in parent instead of child class
- [BUG] TypeScript (fetch) client causes TS7053
- [Bug]Exception in OpenAPI Normalizer - maybe related to handling anyOf HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-generator.