[jaxrs-spec] Add option to use jakarta imports / namespace
Support Jakarta EE in jaxrs-spec.
partially addresses:
https://github.com/OpenAPITools/openapi-generator/issues/13124
https://github.com/OpenAPITools/openapi-generator/issues/6881
To enable jakarta imports, set the additional property useJakartaEE to true. If the option is false the legacy javax.* namespace is imported.
example: java -jar ./openapi-generator-cli.jar generate -g jaxrs-spec --additional-properties=useJakartaEE=true
PR checklist
- [x] Read the contribution guidelines.
- [x] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
- [x] Run the following to build the project and update samples:
Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH. - [x] File the PR against the correct branch:
master(6.1.0) (minor release - breaking changes with fallbacks),7.0.x(breaking changes without fallbacks) - [x] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.
Let me know if you need help fixing it.
Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account
can you please review the build failure when you've time? https://github.com/OpenAPITools/openapi-generator/actions/runs/3183660250/jobs/5383030061
i updated the author info, all build tests passed on circleCI
Hi
It would be nice to fix all Java clients, not only jaxrs-spec. What do you think @thmue @wing328 ?
Hi :-) i think in principle all implementations which depend on jakartaEE could benefit from adding this flag.
right now, under ressources/JavaJaxRS are several independent (?) implementations. There is also one at the root level of this directory (is that still relevant?). Would it be necessary or desired to unify them somehow? (if yes, how?)
@wing328 any chance to merge this PR? or is something missing?
I am very interested in getting this PR merged, as i am working on bumping our Tomcat / JBoss webapps to Jakarta EE 9 spec. The PR looks good to go to me, if the merge conflicts get resolved, but what are your thoughts on this @thmue @wing328 ?
i solved the merge conflict. The failed circleci build on node1 is due to a java version mismatch. I think that this error is not due to this pr.
Caused by: java.lang.UnsupportedClassVersionError: org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
@thmue i have looked into the build problem a bit, and i am almost certain, that it is not due to this PR at all.
I believe, the problem is with the pom template(s) missing a version field for the spring-boot-maven-plugin, which causes maven to pick 3.0.0, which again has transitive dependencies built for java 17.
Try adding a version field in the template; modules/openapi-generator/src/main/resources/java-camel-server/pom.mustache
Something like this;
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${org.springframework.boot.version}</version>
This module is not the only place, i think, this problem exists.
Thank you @shamus13 for debugging this issue. I added the spring version to the pom.xml (samples/server/petstore/java-camel/pom.xml )
Additionally, i added the fix also to the pom.mustache, however, this file does not influence the build
@wing328 would it be possible to get this merged during the 6.3.0 merge window?
Glad to be of help. Anything to get this merged. I really hope, @wing328 can find the time to have a look at this again.
just ran into this on #14319 while working on typescript experimental, hoping it gets merged soon!
It's been a while now, perhaps one the java team could have a look and help speed things along?
@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608
please also run ./bin/utils/ensure-up-to-date to update the doc and the samples.
@thmue looks like some github actions still failed: https://github.com/OpenAPITools/openapi-generator/actions/runs/3788726406/jobs/6441805752. Can you please take a look?
The workflow uses JDK8. Do we need to test it with JDK11 instead?
(there's another workflow to test with JDK11)
it seems that recent versions of jakarta.ws.rs.* (3.1) are only build for 11+
see minimum version : https://jakarta.ee/specifications/restful-ws/3.1/
ok the builds pass now :-)
https://github.com/OpenAPITools/openapi-generator/actions/runs/3788849502/jobs/6446526010 still failed. please take another look.
Before this PR, the build of `samples/serer/petstore/jaxrs-spec) is perfectly fine with JDK8 tought.
I'll another look later this week to see if I find out why.
After generating the sample, three generated model classes
-
EnumTest.java -
NullableClass.java -
HealthCheckResult.java
try to import:
org.openapitools.jackson.nullable
Of course this package does not exist. I don't know where / why this import is generated.
can you please resolve the merge conflicts when you've time? thanks.
@thmue useJakartaEe option already added to all java generators which extends AbstractJavaCodegen. Could you please try 6.3.0 version?
More information can be found here https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/jaxrs-spec.md
@thmue
useJakartaEeoption already added to all java generators which extendsAbstractJavaCodegen. Could you please try 6.3.0 version?More information can be found here https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/jaxrs-spec.md
I use useJakartaEe option for RestTemplate and for WebClient and it works ok
with https://github.com/OpenAPITools/openapi-generator/pull/14310 by @borsch merged, there is no need for this PR anymore. I ll therefore close it, thank you @wing328 for your support.