-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How could I add @lombok.Builder or other annotation in the model object class in Java #324
Comments
Well we do not rely on |
Thanks @jmini, And I want the models for example “Pet” have default builders. Normally I will add the "@builder" Thanks |
As I told, there is no lombok support right now... You can still add the annotations to the generated project after code generation (see the guides project lombok website) and edit the generated files. If you want to generate code with this annotation already in place, you will need to modify the templates. You can do this: just for you locally, or try to contribute it back to the project (then you will need to add an option, because this is not something everybody wants in its project). Our customization doc is a good starting point. Do not hesitate to continue the discussion if you need more information. |
I think it would be good to have a way to add custom annotations while generating the models |
I did make a custom template set that allows you to optionally use Lombok for your models and to optionally include Actuator. You can find these here: This may be a good inclusion to a new release, but I did not want to assume that something like this is on the roadmap. |
Thanks to this PR you can now use Additional annotations for model type like lombok in 4.2.3 release. |
Just to summarise this thread, here is an example of how to setup the maven plugin to generate models with lombok annotations:
|
Hi, trying to use this additionalModelTypeAnnotations feature to add Lombok's annotations - When I use the Spring generator (Server) the generated classes indeed contain the annotations I specified. This is also the case with the Java generator for the client code, but the generated |
As a work around, you can use Templates to generate your own version of |
Yes its working now but now I get this error
Is there a way to specify this annotation only for classes? |
how to use it with openapi-generator-cli-6.1.0.jar ? |
…nrwl-monorepo chore(deps): update nrwl monorepo to v12 (major)
@bharatnpti use additionalModelTypeAnnotations. It's semicolon separated, surrounded by double quotes
|
@qcastel @ericdriggs |
@Serob I guess they just add those annotations without really parsing them. I actually face the same issue than you when using it on a new project. I managed to get it working by adding the option generatedConstructorWithRequiredArgs to false.
|
@Serob yes. This is the expected behavior. In short, the So, in case of using It might look like a lot of work, but it's actually super easy to do (and maintain). |
@Serob Personally, I don't worry about boilerplate on generated code, only functionality. ymmv. |
Is there already have this function?
Thanks
The text was updated successfully, but these errors were encountered: