openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[jaxrs-spec] Add option to use jakarta imports / namespace

Open thmue opened this issue 3 years ago • 2 comments

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:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    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 ./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.

thmue avatar Oct 04 '22 16:10 thmue

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

wing328 avatar Oct 18 '22 09:10 wing328

can you please review the build failure when you've time? https://github.com/OpenAPITools/openapi-generator/actions/runs/3183660250/jobs/5383030061

wing328 avatar Oct 18 '22 09:10 wing328

i updated the author info, all build tests passed on circleCI

thmue avatar Oct 20 '22 08:10 thmue

Hi

It would be nice to fix all Java clients, not only jaxrs-spec. What do you think @thmue @wing328 ?

jorgerod avatar Nov 07 '22 11:11 jorgerod

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?

thmue avatar Nov 07 '22 19:11 thmue

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 ?

shamus13 avatar Dec 05 '22 22:12 shamus13

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 avatar Dec 06 '22 17:12 thmue

@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.

shamus13 avatar Dec 08 '22 22:12 shamus13

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?

thmue avatar Dec 09 '22 23:12 thmue

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.

shamus13 avatar Dec 11 '22 18:12 shamus13

just ran into this on #14319 while working on typescript experimental, hoping it gets merged soon!

davidgamero avatar Dec 22 '22 20:12 davidgamero

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

shamus13 avatar Dec 25 '22 16:12 shamus13

please also run ./bin/utils/ensure-up-to-date to update the doc and the samples.

wing328 avatar Dec 27 '22 15:12 wing328

@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)

wing328 avatar Dec 27 '22 16:12 wing328

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/

thmue avatar Dec 27 '22 16:12 thmue

ok the builds pass now :-)

thmue avatar Dec 27 '22 17:12 thmue

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.

wing328 avatar Dec 28 '22 02:12 wing328

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.

thmue avatar Dec 28 '22 07:12 thmue

can you please resolve the merge conflicts when you've time? thanks.

wing328 avatar Jan 27 '23 02:01 wing328

@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

borsch avatar Feb 15 '23 16:02 borsch

@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

I use useJakartaEe option for RestTemplate and for WebClient and it works ok

jorgerod avatar Feb 15 '23 16:02 jorgerod

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.

thmue avatar Feb 17 '23 20:02 thmue