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

[REQ] [Java] Support of JakartaEE 9

Open RomainPruvostMHH opened this issue 2 years ago • 0 comments

Context

Since Eclipse Foundation is in charge of JakartaEE specifications, it's time to switch to JakartaEE 9 for openapi generator. The first step was to switch to JakartaEE 8 (see the issue #10504). It's done now.

The next step is to upgrade to JakartaEE 9 which means to upgrade to new versions of jakarta's dependencies. But this upgrade is a bit more difficult than the previous because the main goal of JakartaEE 9 is that the javax.* packages to jakarta.* packages have been renamed by Eclipse. I think that it will be necessary to create a new property (named jakartaeeVersion=9 for example) to allow the user to generate the source code with the actual versions of jakartaEE 8 or the last versions of jakartaEE 9.

Describe the solution you'd like

We need to upgrade the following dependencies in the Maven/Gradle/Scala mustache template files. These template files are located in openapi-generator/modules/openapi-generator/src/main/resources.

jakarta.annotation:jakarta.annotation-api:1.3.5 => 2.0.0 jakarta.validation:jakarta.validation-api:2.0.2 => 3.0.0 jakarta.ws.rs:jakarta.ws.rs-api:2.1.6 => 3.0.0 jakarta.json.bind:jakarta.json.bind-api:1.0.2 => 2.0.0 jakarta.json:jakarta.json-api:1.1.6 => 2.0.0 jakarta.xml.bind:jakarta.xml.bind-api:2.3.3 => 3.0.0 jakarta.el:jakarta.el-api:3.0.3 => 4.0.0 jakarta.servlet:jakarta.servlet-api:4.0.4 => 5.0.0 jakarta.activation:jakarta.activation-api:1.2.2 => 2.0.0

The upgrade of jakarta versions will force us to replace all javax.* import by jakarta.* in the mustache templates.

Then, we need a new property named jakartaeeVersion to keep the generation source code as is (with the package javax.* ) or to use the new jakartaEE 9 classes in the generated source code. By default, if the property didn't set, we consider that we are still on jakartaEE 8 (javax.*).

Beware, some samples are dependents of Spring Boot. For them, it will be necessary to upgrade the version of spring boot parent to 3 (release in September 2022). It is not part of the scope of this issue.

How to validate the request

We need to create an unit test with the property jakartaeeVersion. The versions of depedencies should be equal to the versions above. And of course, we need to create a new java sample with the new property.

Additional context

Versions of JakartaEE 9 : https://projects.eclipse.org/releases/jakarta-ee-9. Or a map here https://jakarta.ee/release/9/ Explanations of JakartaEE 9 release plan : https://eclipse-ee4j.github.io/jakartaee-platform/jakartaee9/JakartaEE9ReleasePlan

RomainPruvostMHH avatar Aug 07 '22 14:08 RomainPruvostMHH

This has been a request for two years now:

https://github.com/OpenAPITools/openapi-generator/issues/6881

bmarwell avatar Sep 14 '22 05:09 bmarwell