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] config option useJakartaEe in java generator has no effect #19398

Closed
5 of 6 tasks
fkohl04 opened this issue Aug 20, 2024 · 1 comment · Fixed by #19469
Closed
5 of 6 tasks

[BUG] config option useJakartaEe in java generator has no effect #19398

fkohl04 opened this issue Aug 20, 2024 · 1 comment · Fixed by #19469

Comments

@fkohl04
Copy link

fkohl04 commented Aug 20, 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?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When executing a code generation for the provided specification with 7.7.0 the generated file will contain validation annotation from the package "javax.validation". When doing the same in version 7.8.0 the corresponding annotations are imported from the package "jakarta.validation", even though there is a config option "useJakartaEe" that is set to false and claims to control this behavior.

openapi-generator version

7.8.0 contains the issue

7.7.0 is working fine

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  version: 1.0.0
  title: Test
  description: Test
paths: {}
components:
  schemas:
    test:
      type: object
      required:
        - test
      properties:
        test:
          type: string
          minLength: 19
Generation Details

Gradle plugin definition:

task generateTest(type: GenerateTask)
tasks.named("generateCustomerEvent").get().setProperty("inputSpec", "PutLocationOfFileHere")

tasks.withType(GenerateTask).configureEach {
  generatorName = "java"
  outputDir = "${buildDir}/generated/sources"

  configOptions = [
    performBeanValidation: "true",
    useBeanValidation: "true",
    library: "webclient",
    dateLibrary: "custom",
    useJakartaEe: "false"
  ]
  globalProperties = [
    apis: "false",
    models: ""
  ]
  typeMappings = [
    DateTime: "Instant",
    Date: "java.time.LocalDate",
    Uuid: "UUID"
  ]
  importMappings = [
    Instant: "java.time.Instant",
    UUID: "java.util.UUID"
  ]
}
Steps to reproduce

Execute the generation for the provided specification in version 7.7.0 and 7.8.0.

@horaceli
Copy link
Contributor

horaceli commented Aug 27, 2024

#18332 and #19171 aligned the validation-api to use jakarta.* package as a previous commit had already upgraded the validation-api version to 3.x. Unfortunately this caused a regression as end users can manually specify 2.x, in which case they would still need the javax.* package.

I'll raise a PR to fix this in the coming days

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

Successfully merging a pull request may close this issue.

2 participants