-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[REQ] Support SpringBoot 3.0 GA for Java-based API code generation #14143
Comments
Same here... |
@kpupkov-ppa @maxl2287 you can use config property https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/spring.md changes are here - https://github.com/OpenAPITools/openapi-generator/pull/12407/files#diff-9de34b4aad5de707e8aa0c031f20a6573f8f50826a437f0652c54b3788b37d41R434 |
The same problem applies to the "java" code generator (client side). We're using java with webclient generator, and the templates use javax.annotation packages that are incompatible with a spring boot 3 application. |
@borsch |
@ComputerDaddyGuy mentioned over in the swagger-codegen github repo the following workaround:
source: swagger-api/swagger-codegen#11797 (comment) The idea is to generate the code as usual but modify it automatically afterward. I'm not a huge fan of this approach but as a workaround, it's "ok". |
We also need Spring Boot 3.0.0 support for Kotlin-Spring. Should this be a separate issue? |
Never mind. There is already an issue for Kotlin-Spring: #13578. |
The solution for this problem would be the use of customised mustache templates in your project. Just copy original templates in a project folder and modify some or all of them by replacing "javax" with "jakarta"... |
@aleksbal IMHO this is not a solution but another workaround. This whole problem could have been handled years ago (since November 2020 the Jakarta EE 9 spec was released). Why java/jvm wide?
E.g. the spring generator has a
To be honest, this is not a great experience. |
Well, I think it is legit to use customised mustache templates for code generation in order to solve some specific project needs. However I agree that javax/jakarta problem is not really "the specific one" but rather the one which affects the whole ecosystem.
Actually they've bee trying, for example, if you have a look in the templates from OpenAPI generator's Java Spring module (v6.2.1) you will find a flag called "useJakartaEe", which determines whether to generate the Java classes using "javax." or "jakarta."... |
I however was not able to utilise the "useJakartaEe", just have seen it in the templates but to set the flag to true or false didn't work for me, so I adjusted the original templates to fit our needs. I would appreciate any example which demonstrates the usability. Thx. |
@borsch mea culpa. I verified it again and the one project which had this issue is using custom templates, which use the javax namespace. 🤦 Sorry, I didn't see that. |
Hi @borsch, when using generator java with library webclient the generated code still contains javax.* instead of jakarta.*, even with the config option |
@alwibrm webclient doesn't yet support neither SB3 nor jakarta. This change is in progress |
@borsch Thanks for the quick reply. Is there an open issue for that or a planned release version/date? |
@borsch You mentioned the change for webclient was in progress. Is there any issue or merge request for this? Otherwise I would consider contributing a merge request. |
FYI: with #14343 it is now possible to enable |
Hi. I am trying to upgrade our project to spring-boot 3. During this I encountered the javax/jakarta issue. Upgraded the openapi-generator to 6.2.0 and made the setting |
@LSzelecsenyi If this reference is inside the generated code, this is odd. |
@kpupkov-ppa , could you please try the latest 6.3.0 release if your requiment is met? |
@mlemnian Thanks for the reply. |
@LSzelecsenyi please try |
@parenko
Tried with 6.3.0 but without the replacer I am getting the same error: package javax.ws.rs.core does not exist |
For me it worked with 6.2.1 and 6.3.0 with configOption |
|
The config option Unfortunately the build is still broken because of a cannot find symbol exception in This is because there are two different versions of swagger-annotations on the classpath, 1.6.8 and 2.2.4:
|
@LSzelecsenyi ok, I don't see any obvious mistakes. |
@LSzelecsenyi could you also share your |
For feature readers, I solved the issue by adding these dependencies to my project plus
|
I'm using the https://github.com/int128/gradle-swagger-generator-plugin plugin along with openapi-generator-cli version 6.6.0 and I am also noticing this for: How are people working around this issue? I seem to have the correct annotations bytecode since my version of Schema on classpath doesn't have the requiredCode property or RequiredMode. It seems to be a problem with the model code generation using the outdated requiredMode property. Is that a problem in the mustache template? Is there any workaround? |
The workaround ended up being:
|
Any update guys? |
Thanks to @laidani I was able to get passed the
|
@kpupkov-ppa correct me if i'm wrong, but as far as i understand code generation for java with spring boot 3 is working fine nowadays … if you agree, kindly close this issue. |
There is still problem with the generated controllers which use javax annotation imports. |
@tukez as far es I can see the imports are all fine if you use the |
@pstorch Thank you, that is correct. It was some Eclipse problem which was corrected once I manually deleted the old generated file (Eclipse clean was not enough for some reason). |
@tukez @kpupkov-ppa as confirmed now, Closing this issue for now. Should anyone come across a specific java generator that doesn't respect these flags correctly, kindly open a new issue so they can be targeted and fixed in more atomic PRs. |
Is your feature request related to a problem? Please describe.
We need a new way to generate API with
jakarta
annotations in codeDescribe the solution you'd like
all
javax.XXXX
is no longer supported and replaced byjakarta
Describe alternatives you've considered
no alternative
Additional context
https://spring.io/blog/2022/11/24/spring-boot-3-0-goes-ga
The text was updated successfully, but these errors were encountered: