This enhancement would allow generation of models using Lombok's @Value annotation instead of a POJO with getters and setters.
2.1.6
Please vote for this issue if interested or comment if you are planning a PR on this.
I know a lot of people who don't like Lombok very much so this should be at most an option. And since we generate the getters and setters, the interest of Lombok is limited here.
It's not just the @Value, also a @Builder would make sense for constructing those DTOs.
We generate fluent setters which provide about the same thing.
It would be nice to have as an option... I really would like that feature.
It also think it would be great to have the possibility of adding custom annotations (not just Lombok) on field and class level. Since we consistently use Lombok in our projects this is a limitation...
I had a look at this, seeing if I can add this functionality via a pull request. The biggest stumbling block I found is the fact that Lombok does not do the @Builder pattern properly for super classes -.ie When class A extends B, the builder pattern does not propagate to the parent class. It has been documented all over the web, and I'm waiting in anticipation to see if https://github.com/rzwitserloot/lombok/pull/1337 will be able to crack it. Just a note @Value wont work, cause @Value makes classes final, so Cat won't be able to extend Animal. From what I can see the annotation would look something like this:
@Builder
@Getter
@EqualsAndHashCode(callSuper = true)
@ToString
But even that is a problem since using Lombok's toString annotation means you're loosing out on the "toIndentedString(java.lang.Object o) method from the swagger code. So you're left with:
@Builder
@Getter
@EqualsAndHashCode(callSuper = true)
And if you're not willing to wait for the @Builder to be finished, you're left with:
@Getter
@EqualsAndHashCode(callSuper = true)
So what would you settle with?
Has this feature implemented now?
Is there any work done? on any branch? I'm willing to contribute
You can actually achieve great success with editing the templates, took a few hours to do it. Willing to share it if needed...
May I am wrong, but if you define your custom template for example to add Lombok (what I would find nice), do you lose any template improvement that could potentially come in a new version of codegen? Is it any way to just extend the template and not completely replace? Thx!
This this this this! Very fucking useful. I currently use json2lombok IntelliJ IDEA plugin, but it does not come with json schema information.
I started a little fork with basic lombok support. Very WIP at the moment but it's something to work off of
https://github.com/gavin-haynes-grow/swagger-codegen/tree/support-lombok
Swagger Codegen is a waste of time resources. Better use Open API v3 code generator. I started to make some Java 11 + Lombok + Spring Boot 2 templates.
ok. Looks there's a lombok PR here for openapi-generator https://github.com/OpenAPITools/openapi-generator/pull/5430
Most helpful comment
It's not just the
@Value, also a@Builderwould make sense for constructing those DTOs.