OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.76k stars 6.56k forks source link

Java libraries validation-api may use javax imports but dependency always uses jakarta namespace #19171

Closed horaceli closed 3 months ago

horaceli commented 3 months ago

18332 replaced instances of {{javaPackage}}.validation with jakarta.validation because all generated poms under Java/libraries use jakarta.validation:jakarta.validation-api:3.0.2 (which uses jakarta package namespace).

However a couple of moustache templates were missed out, so if useJakartaEe flag was disabled, some code would still require javax.validation.* while some would require jakarta.validation.* - this PR fixes that by aligning with the package included in the generated pom.

Note that this issue only affects jakarta.validation-api and not jakarta.annotation-api. Annotation API uses different versions in the pom depending on the userJakartaEe flag, e.g. https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache#L360

PR checklist

wing328 commented 3 months ago

thanks for the fix.

I was able to repeat the issue and confirmed the fix

[INFO] --- source:3.2.0:jar-no-fork (attach-sources) @ openapi-java-client ---
[INFO] Building jar: C:\Users\wing3\AppData\Local\Temp\resteasy234a\target\openapi-java-client-1.0.0-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  14.329 s
[INFO] Finished at: 2024-07-18T16:59:21+08:00
[INFO] ------------------------------------------------------------------------