Skip to content

[kotlin] Add MicroProfile REST client support - #25374

Merged
wing328 merged 8 commits into
OpenAPITools:masterfrom
rm127:feature/kotlin-microprofile-client
Nov 2, 2026
Merged

wing328 merged 8 commits into
OpenAPITools:masterfrom
rm127:feature/kotlin-microprofile-client

Conversation

@rm127

@rm127 rm127 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Related to #12065: adds Kotlin MicroProfile clients usable with Quarkus, not the server-generation portion of that request.

Adds library=jvm-microprofile to the Kotlin client generator so MicroProfile applications can use Kotlin interfaces and models instead of Java platform types, while retaining their runtime's transport, authentication and header providers.

  • Supports MicroProfile Rest Client 3.0/Jakarta or 2.0/javax, Jackson, optional Mutiny Uni<T>, and explicit or class-derived configuration keys.
  • Preserves nullable parameters/responses and uses Uni<Void?> for bodyless operations. Required nullable fields require JSON presence; required non-null fields reject explicit null, including primitives.
  • Supports discriminator-based allOf and discriminated object oneOf/anyOf interfaces, including alternatives shared between unions.
  • Enables JVM default methods and packages META-INF/beans.xml so separately built client JARs can be discovered by CDI/Quarkus.
  • Rejects incompatible serializers/reactive options, Android Room models, multipart operations and unsupported query serialization instead of silently generating incorrect transport behavior.

The hierarchy repair is related to #19928 and #22013, but is scoped to this new library; it does not fix those reports' Moshi/Spring configurations. Other Kotlin client libraries retain their existing behavior.

Undiscriminated unions, complete JSON Schema validation and missing-versus-null tracking are outside scope. Jackson's Kotlin module is required; strict collection-element null checking remains a runtime configuration.

Verification

130 targeted generator tests and Checkstyle pass, including a non-MicroProfile Jackson formatting regression. The generated sample has 17 passing real-HTTP Quarkus tests covering polymorphism, nullability, errors, bodyless responses and combined header-factory/header-parameter/filter decorations. Separate-JAR consumption also passes in a Quarkus acceptance harness. Generated sample changes are confined to this library.

PR checklist

  • Read the contribution guidelines.
  • Run the full project build, regenerate all affected samples and export generator documentation. Targeted reactor builds/tests and this library's sample regeneration are complete; the full repository-wide regeneration has not been run.
  • Request review from the Kotlin technical committee.

@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 23 files

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

Comment thread modules/openapi-generator/pom.xml Resolved
Comment thread docs/generators/kotlin.md Resolved
Generate Kotlin-native clients for MicroProfile runtimes with optional Mutiny APIs, preserving Kotlin nullability at service boundaries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rm127
rm127 force-pushed the feature/kotlin-microprofile-client branch from 9718147 to b6ecb9b Compare October 23, 2026 06:25
rm127 and others added 2 commits October 23, 2026 08:34
Reject unsupported query formats instead of silently changing the contract, compile against matching MicroProfile API versions, and document Kotlin nullability accurately.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make discriminated alternatives implement their union interfaces, reject invalid required JSON values, and include CDI discovery metadata for separate client JARs. Extend the generated sample and real-HTTP regression coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@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 29 files (changes from recent commits).

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

View guided diff | Re-trigger cubic

Keep shared Jackson formatting unchanged outside MicroProfile, reject unsupported Android Room generation, and link inherited properties from concrete model documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wing328

wing328 commented Oct 24, 2026

Copy link
Copy Markdown
Member

thanks for the PR

i tried to build the project with your change locally (windows box) but got the following errors:

[ERROR] Errors:
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithOpenApi31_PreservesNullableTypes
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithOpenApi31_PreservesNullableTypes:138 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithOpenApi31_PreservesNullableTypes:138 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithOpenApi31_PreservesNullableTypes:138 ? ClassNotFound org.openapitools.client.apis.PetApi
[INFO]
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithSerializableUnionModels_CompilesAllInterfaces
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithSerializableUnionModels_CompilesAllInterfaces:123 ? ClassNotFound org.openapitools.client.models.Choice
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithSerializableUnionModels_CompilesAllInterfaces:123 ? ClassNotFound org.openapitools.client.models.Choice
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithSerializableUnionModels_CompilesAllInterfaces:123 ? ClassNotFound org.openapitools.client.models.Choice
[INFO]
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin(java.lang.String, boolean, java.lang.String)[0]
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[INFO]
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin(java.lang.String, boolean, java.lang.String)[1]
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[INFO]
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin(java.lang.String, boolean, java.lang.String)[2]
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[INFO]
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin(java.lang.String, boolean, java.lang.String)[3]
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi

can you please review the errors when you've time?

Select generated sources with native Path components and reject empty source lists before compilation. Preserve exact generator whitespace in checked-in MicroProfile samples so CI regeneration has no diff.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rm127

rm127 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

thanks for the PR

i tried to build the project with your change locally (windows box) but got the following errors:

[ERROR] Errors:
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithOpenApi31_PreservesNullableTypes
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithOpenApi31_PreservesNullableTypes:138 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithOpenApi31_PreservesNullableTypes:138 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithOpenApi31_PreservesNullableTypes:138 ? ClassNotFound org.openapitools.client.apis.PetApi
[INFO]
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithSerializableUnionModels_CompilesAllInterfaces
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithSerializableUnionModels_CompilesAllInterfaces:123 ? ClassNotFound org.openapitools.client.models.Choice
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithSerializableUnionModels_CompilesAllInterfaces:123 ? ClassNotFound org.openapitools.client.models.Choice
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithSerializableUnionModels_CompilesAllInterfaces:123 ? ClassNotFound org.openapitools.client.models.Choice
[INFO]
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin(java.lang.String, boolean, java.lang.String)[0]
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[INFO]
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin(java.lang.String, boolean, java.lang.String)[1]
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[INFO]
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin(java.lang.String, boolean, java.lang.String)[2]
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[INFO]
[ERROR] org.openapitools.codegen.kotlin.KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin(java.lang.String, boolean, java.lang.String)[3]
[ERROR]   Run 1: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 2: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi
[ERROR]   Run 3: KotlinMicroprofileClientCodegenTest.generate_WithSupportedRuntime_CompilesKotlin:59 ? ClassNotFound org.openapitools.client.apis.PetApi

can you please review the errors when you've time?

Of course! This should be resolved with the latest commit.

@@ -0,0 +1,13 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-jvm-microprofile-mutiny

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you please add the new folder to the github workflow for testing kotlin clients?

https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/samples-kotlin-client.yaml

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added it to the list. Is that what you meant?

Build the generated library in the Kotlin client matrix and run its real-HTTP integration suite. Use JDK 17 for this Quarkus sample while preserving JDK 11 for existing entries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@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 1 file (changes from recent commits).

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

View guided diff | Re-trigger cubic

Keep the maintainer-requested sample list addition without a custom JDK or integration-test step.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@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 1 file (changes from recent commits).

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

View guided diff | Re-trigger cubic

Use JDK 17 and cached Maven dependencies for the Quarkus HTTP tests instead of invoking a missing Gradle wrapper. Preserve existing Gradle jobs unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wing328
wing328 merged commit e71e036 into OpenAPITools:master Nov 2, 2026
134 of 135 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants