Skip to content

[Java][Client][MicroProfile] Add microprofileRegisterRestClient option - #25281

Open
karan-rastogi wants to merge 5 commits into
OpenAPITools:masterfrom
karan-rastogi:feat-25264-microprofile-register-rest-client-option
Open

karan-rastogi wants to merge 5 commits into
OpenAPITools:masterfrom
karan-rastogi:feat-25264-microprofile-register-rest-client-option

Conversation

@karan-rastogi

@karan-rastogi karan-rastogi commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and the Pull Request label is correctly set.
  • Pull Request is based on the master branch of the repository.
  • Ran mvn clean package in the root of the repository and it passed.
  • There is a GitHub issue describing the problem, and this Pull Request fixes it.

PR Type

New feature

Description of the changes

When generating a Java client with library=microprofile, the generated API interfaces are always annotated with @RegisterRestClient.

In some use cases, these interfaces are intended to serve as base contracts extended by application-owned CDI REST clients. In that scenario, the base interface should not be registered as a CDI REST client itself.

This PR adds a new boolean config option microprofileRegisterRestClient (default: true) that controls generation of both:

  • The @RegisterRestClient annotation
  • Its corresponding import

When set to false, the rest of the generated code is unchanged (JAX-RS annotations, operation signatures, return types). Default behavior (true) preserves existing output.

Verification

  1. Built the generator:

    ./mvnw clean package -DskipTests
    
  2. Generated clients with library=microprofile and verified both cases:

    Default (true):

    grep "RegisterRestClient" src/main/java/.../PetApi.java
    → 2 matches (import + annotation)
    

    Option false:

    grep "RegisterRestClient" src/main/java/.../PetApi.java
    → 0 matches
    
  3. Added unit tests in JavaClientCodegenTest:

    • testMicroprofileRegisterRestClientDefaultTrue — verifies annotation present by default
    • testMicroprofileRegisterRestClientDisabled — verifies annotation and import omitted when false

    Both tests pass:

    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
    

Related issues

Technical committee

@OpenAPITools/openapi-generator-java-technical-committee


Summary by cubic

Adds a microprofileRegisterRestClient option (default: true) to the Java client generator for the microprofile library, allowing generated API interfaces to omit the @RegisterRestClient annotation and its import when set to false.

This lets generated interfaces be used as base contracts extended by application-owned CDI REST clients, without registering the base interface itself. When disabled, the rest of the generated code is unchanged.

  • Adds the boolean CLI option and wires it through processOpts.
  • Guards the annotation and import in the MicroProfile api.mustache template with the option.
  • Adds unit tests covering both the default (true) and disabled (false) cases.
  • Regenerates MicroProfile samples and generator docs (including removal of extra blank lines in generated APIs).

Fixes #25264.

Written for commit 29244b8. Summary will update on new commits.

View guided diff

@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.

All reported issues were addressed across 3 files

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

View guided diff | Re-trigger cubic

Add a new boolean option microprofileRegisterRestClient (default: true)
to control whether the generated MicroProfile API interfaces are annotated
with @RegisterRestClient and import the annotation.

When set to false, the annotation and its import are omitted from the
generated interfaces, allowing them to be used as base contracts extended
by application-owned REST clients, without registering the generated
base interface as a separate CDI REST client.

The rest of the generated code is unchanged: JAX-RS annotations, operation
signatures, and return types remain identical.

Default behavior (true) preserves existing output.

Added unit tests to verify both the default (true) and disabled (false)
cases.

Fixes OpenAPITools#25264
@karan-rastogi
karan-rastogi force-pushed the feat-25264-microprofile-register-rest-client-option branch from cc1973f to edca58d Compare October 17, 2026 06:55
@karan-rastogi
karan-rastogi force-pushed the feat-25264-microprofile-register-rest-client-option branch from da39c2c to 8028f16 Compare October 17, 2026 07:18
@karan-rastogi

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai please re-review the latest changes.

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai please re-review the latest changes.

@karan-rastogi I have started the AI code review. It will take a few minutes to complete.

@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.

No issues found across 52 files

View guided diff | Re-trigger cubic

@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.

All reported issues were addressed across 8 files (changes from recent commits).

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

View guided diff | Re-trigger cubic

Comment thread docs/generators/fsharp-functions.md Resolved
@karan-rastogi

karan-rastogi commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @wing328 !

Just a quick note on the failing CI check: Samples Java Client JDK11 / Build Java Client JDK11 (samples/client/petstore/java/retrofit2-play26). This looks like a pre-existing issue in the master branch (a duplicate jakarta.validation-api dependency), unrelated to the changes in this MicroProfile PR.

All 139 other checks, including the MicroProfile tests and AI review, are passing successfully.

Please let me know if there's anything else needed from my side. Thanks for your time!

@wing328 wing328 added this to the 7.27.0 milestone Oct 21, 2026
@wing328

wing328 commented Oct 21, 2026

Copy link
Copy Markdown
Member

thanks for the PR

https://github.com/OpenAPITools/openapi-generator/actions/runs/39015368208/job/117346270329?pr=25281 already fixed in the latest master

cc @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08) @KannaKim (2026/07)

@karan-rastogi

Copy link
Copy Markdown
Contributor Author

Thanks @wing328! Done. Moved the closing tags to separate lines and regenerated the samples.

This branch has not been deployed

No deployments
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.

[REQ][Java][Client][MicroProfile] Add an option to omit @RegisterRestClient during client generation

2 participants