Skip to content

[BUG][Java][microprofile] oneOf interface ignores useJakartaEe for @Generated annotation #24889

Description

@svifred

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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

With the Java generator, the microprofile library, Jackson serialization, and useJakartaEe=true, enabling useOneOfInterfaces=true generates the oneOf interface with @javax.annotation.Generated rather than @jakarta.annotation.Generated.

This occurs with both useSealedOneOfInterfaces=false and useSealedOneOfInterfaces=true. The sealed option is not the cause; both modes use the shared oneOf interface template.

This makes generated models fail to compile in a Jakarta-only application, including Quarkus 3, unless the consumer adds a compile-only javax.annotation:javax.annotation-api dependency solely for the generated annotation.

The same result is produced when useSealedOneOfInterfaces is omitted or set to false.

The generated oneOf interface contains:

@javax.annotation.Generated(...)
public sealed interface Request permits NormalRequest, EmergencyRequest {
}

The generated code fails in a Jakarta-only project because javax.annotation.Generated is absent.

With useJakartaEe=true, the generated oneOf interface should contain:

@jakarta.annotation.Generated(...)
public sealed interface Request permits NormalRequest, EmergencyRequest {
}
openapi-generator version

7.24.0. Probably not a regression.

OpenAPI declaration file content or url

Minimal OpenAPI 3.0.3 document:

openapi: 3.0.3
info:
  title: oneOf Jakarta test
  version: 1.0.0
paths: {}
components:
  schemas:
    Request:
      oneOf:
        - $ref: "#/components/schemas/NormalRequest"
        - $ref: "#/components/schemas/EmergencyRequest"
    NormalRequest:
      type: object
      properties:
        kind:
          type: string
          enum: [normal]
    EmergencyRequest:
      type: object
      properties:
        kind:
          type: string
          enum: [emergency]
Generation Details

Generation options:

generatorName=java
library=microprofile
serializationLibrary=jackson
useJakartaEe=true
useOneOfInterfaces=true
useSealedOneOfInterfaces=true
Steps to reproduce
  1. Save above reproducing yaml to file
  2. Generate using options given above
  3. Inspect @Generated statements of generated model
Related issues/PRs
Suggest a fix

Ensure the shared oneOf interface generation path resolves @Generated through the generator's configured javaxPackage, as the regular Java/MicroProfile model generation path does.

Please add regression coverage for the Java microprofile library with Jackson, useJakartaEe=true, useOneOfInterfaces=true, and useSealedOneOfInterfaces=true; assert that the generated oneOf interface uses jakarta.annotation.Generated.

Workaround

Consumers can add:

compileOnly "javax.annotation:javax.annotation-api:1.3.2"

Generated has source retention, so this is a compile-time bridge only. It should not be necessary when useJakartaEe=true.


Note: This issue was reported with AI assistance. The reproduction and generated output were verified by the reporter.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions