Skip to content
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

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

Closed
wants to merge 13 commits into from

Conversation

thmue
Copy link

@thmue thmue commented Oct 4, 2022

Support Jakarta EE in jaxrs-spec.
partially addresses:
#13124
#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

  • Read the contribution guidelines.
  • 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.
  • 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.
  • File the PR against the correct branch: master (6.1.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328
Copy link
Member

wing328 commented Oct 18, 2022

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
Copy link
Member

wing328 commented Oct 18, 2022

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

@thmue
Copy link
Author

thmue commented Oct 20, 2022

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

@wing328 wing328 modified the milestones: 6.2.1, 6.3.0 Nov 1, 2022
@jorgerod
Copy link
Contributor

jorgerod commented Nov 7, 2022

Hi

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

@thmue
Copy link
Author

thmue commented Nov 7, 2022

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?

@shamus13
Copy link
Contributor

shamus13 commented Dec 5, 2022

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 ?

@thmue
Copy link
Author

thmue commented Dec 6, 2022

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 thmue changed the title [jaxrs-spec] Add option to use jakarta imports / namespace [Java][jaxrs-spec] Add option to use jakarta imports / namespace Dec 8, 2022
@shamus13
Copy link
Contributor

shamus13 commented Dec 8, 2022

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

@thmue
Copy link
Author

thmue commented Dec 9, 2022

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?

@shamus13
Copy link
Contributor

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.

@davidgamero
Copy link
Contributor

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

@shamus13
Copy link
Contributor

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

@@ -0,0 +1,11 @@
generatorName: jaxrs-spec
outputDir: samples/server/petstore/jaxrs-spec
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the output folder cannot be the same. please change it to samples/server/petstore/jaxrs-spec-ee instead

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also update .github/workflows/samples-jaxrs.yaml with the new output directory

@@ -0,0 +1,11 @@
generatorName: jaxrs-spec
outputDir: samples/server/petstore/jaxrs-spec
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml (3.0 spec) for testing as we're moving away from 2.0 spec.

@wing328
Copy link
Member

wing328 commented Dec 27, 2022

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

@thmue thmue requested a review from jimschubert as a code owner December 27, 2022 16:34
@wing328
Copy link
Member

wing328 commented Dec 27, 2022

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

@thmue
Copy link
Author

thmue commented Dec 27, 2022

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
Copy link
Author

thmue commented Dec 27, 2022

ok the builds pass now :-)

@wing328
Copy link
Member

wing328 commented Dec 28, 2022

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.

@thmue
Copy link
Author

thmue commented Dec 28, 2022

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.

@wing328 wing328 modified the milestones: 6.3.0, 6.3.1 Jan 20, 2023
@wing328
Copy link
Member

wing328 commented Jan 27, 2023

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

@borsch
Copy link
Member

borsch commented Feb 15, 2023

@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

@jorgerod
Copy link
Contributor

@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

@thmue
Copy link
Author

thmue commented Feb 17, 2023

with #14310 by @borsch merged, there is no need for this PR anymore. I ll therefore close it, thank you @wing328 for your support.

@thmue thmue closed this Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants