Skip to content

[java][microprofile] Extend useSealedOneOfInterfaces support to the microprofile library#24267

Open
Ignacio-Vidal wants to merge 1 commit into
OpenAPITools:masterfrom
Ignacio-Vidal:mp-client-sealed
Open

[java][microprofile] Extend useSealedOneOfInterfaces support to the microprofile library#24267
Ignacio-Vidal wants to merge 1 commit into
OpenAPITools:masterfrom
Ignacio-Vidal:mp-client-sealed

Conversation

@Ignacio-Vidal

@Ignacio-Vidal Ignacio-Vidal commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Extends useSealedOneOfInterfaces to the microprofile library of the java client generator (Jackson serialization). Follow-up to #24190, which added useOneOfInterfaces support for microprofile; with both flags set, the generated oneOf interface is sealed and permits its subtypes, which become final classes implementing it — matching the existing WebClient/RestClient behaviour of the same option.

public sealed interface PetRequest permits CatRequest, DogRequest { ... }
public final class CatRequest implements PetRequest { ... }

Changes

  • Java/libraries/microprofile/pojo.mustache: reference the shared {{>sealed}}/{{>permits}} partials on the class declaration, so permitted subtypes become final (a sealed interface requires its permitted subtypes to be final/sealed/non-sealed). No-op when the flag is off.
  • JavaClientCodegen: force Java 17 for the microprofile library when useSealedOneOfInterfaces is set (sealed types require Java 17); CliOption description updated to include microprofile.
  • microprofile/pom_3.0.mustache: emit java.version 17 when java17 is set (11 otherwise).
  • Test JavaClientCodegenTest#sealedOneOfInterfaceMicroprofileJackson (sealed interface + final children + pom at 17); the existing oneOfInterfaceMicroprofileJackson test guards the flag-off default (not sealed, not final).
  • New sample microprofile-oneof-sealed (Java 17), registered in the samples-java-client-jdk17.yaml workflow (push/PR paths + build matrix). The sample compiles under JDK 17.

Default output is unchanged: the partials are gated on the flag, and a full sample regeneration produces no diffs outside this PR's own sample and docs.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

cc Java technical committee: @bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @martin-mfg

@Ignacio-Vidal Ignacio-Vidal marked this pull request as ready for review July 9, 2026 21:54
When useSealedOneOfInterfaces=true, render the generated oneOf interface as a
sealed interface and its subtypes as final classes in the microprofile library
(Jackson serialization), matching the existing WebClient/RestClient behaviour
of the option.

- microprofile pojo.mustache: add the shared {{>sealed}}/{{>permits}} partials to
  the class declaration so permitted children become final (a sealed interface
  requires its permitted subtypes to be final/sealed/non-sealed).
- JavaClientCodegen: force Java 17 for the microprofile library when
  useSealedOneOfInterfaces is set (sealed types require Java 17); CliOption
  description updated to include microprofile.
- pom_3.0.mustache: emit java.version 17 when java17 is set.
- Test JavaClientCodegenTest#sealedOneOfInterfaceMicroprofileJackson.
- New microprofile-oneof-sealed sample (Java 17), registered in the
  samples-java-client-jdk17.yaml workflow.

Default output is unchanged; the partials are gated on the flag.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread .github/workflows/samples-java-client-jdk17.yaml
@Ignacio-Vidal

Copy link
Copy Markdown
Contributor Author

@wing328 - Any chance you can review a follow up of #24190?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant