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

[BUG JavaSpring] Use useJakartaEe=true and useSpringBoot3=false should generate a library with Spring Boot 2 + JDK17 support + Jakarta proper dependencies #19861

Open
5 tasks done
mgvinuesa opened this issue Oct 14, 2024 · 1 comment

Comments

@mgvinuesa
Copy link

mgvinuesa commented Oct 14, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?

Actual: A pom.xml with java.version to 8 and source that it does not compile
Expected: A pom.xml file with java.version to 17 and the jakarta.validation-api and jakarta.annotation dependencies.

Description
openapi-generator version

v7.9.0

OpenAPI declaration file content or url

Anyone, you can find the full example here: https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml

Generation Details

I need to generate a Spring Boot 2 and JDK17 compatible library. For that I use the following command:

java -jar openapi-generator-cli-7.9.0.jar generate -i openapi.yaml -g spring --additional-properties apiPackage=com.example.api.v1,artifactId=api-petstore,groupId=com.example.api,artifactVersion=1.0.0-SNAPSHOT,dateLibrary=java8,library=spring-boot,useJakartaEe=true,useSpringBoot3=false,useSpringController=false,skipDefaultInterface=true,modelPackage=com.example.model.v1,interfaceOnly=true,useSwaggerUI=false,useTags=true -o petstore_interface_only_sb2_jdk17 --global-property models,apis,supportingFiles=pom.xml

And then execute

mvn clean package

We choose useJakartaEe=true and useSpringBoot3=false. The output is a project that it does not compile, due to we are including jakarta packages but spring does not import the proper version of jakarta.validation and jakarta.annotation. Apart of this java.version should be 17.

Compile errors:

[ERROR] /C:/petstore_interface_only_sb2_jdk17/src/main/java/com/example/api/v1/StoreApi.java:[30,1] package jakarta.validation.constraints does not exist
[ERROR] /C:/petstore_interface_only_sb2_jdk17/src/main/java/com/example/model/v1/Customer.java:[13,26] package jakarta.validation does not exist
[ERROR] /C:/petstore_interface_only_sb2_jdk17/src/main/java/com/example/model/v1/Customer.java:[19,26] package jakarta.annotation does not exist

...
[ERROR] /C:/petstore_interface_only_sb2_jdk17/src/main/java/com/example/model/v1/Customer.java:[25,2] cannot find symbol
[ERROR]   symbol: class Generated

...

[ERROR] /C:/petstore_interface_only_sb2_jdk17/src/main/java/com/example/model/v1/Pet.java:[122,4] cannot find symbol
[ERROR]   symbol:   class NotNull
[ERROR]   location: class com.example.model.v1.Pet

...

[ERROR]   location: class com.example.model.v1.Customer
[ERROR] /C:/petstore_interface_only_sb2_jdk17/src/main/java/com/example/model/v1/Customer.java:[92,4] cannot find symbol
[ERROR]   symbol:   class Valid
[ERROR]   location: class com.example.model.v1.Customer
Related issues/PRs

I think these are similar, but only for java libraries:
#19398
#19437
#19171

Suggest a fix

I suppose that I can fix the template including some if/else conditions but I don't know if I have to consider other things.

@mgvinuesa mgvinuesa changed the title [BUG JavaSpring] Use useJakartaEe=true and useSpringBoot3=false must generate a library with Spring Boot 2 + JDK17 support + Jakarta proper dependencies [BUG JavaSpring] Use useJakartaEe=true and useSpringBoot3=false should generate a library with Spring Boot 2 + JDK17 support + Jakarta proper dependencies Oct 14, 2024
@wing328
Copy link
Member

wing328 commented Nov 17, 2024

I suppose that I can fix the template including some if/else conditions but I don't know if I have to consider other things.

I wonder if you can file a PR to start with and we will review accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants