Improve consumption of primitive types as body#23257
Merged
wing328 merged 4 commits intoOpenAPITools:masterfrom Mar 15, 2026
Merged
Improve consumption of primitive types as body#23257wing328 merged 4 commits intoOpenAPITools:masterfrom
wing328 merged 4 commits intoOpenAPITools:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
10 issues found across 28 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt">
<violation number="1" location="samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt:279">
P2: `text/plain` primitive handling excludes `Char`, so single-character bodies still throw `UnsupportedOperationException`.</violation>
</file>
<file name="samples/client/echo_api/kotlin-jvm-okhttp/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt">
<violation number="1" location="samples/client/echo_api/kotlin-jvm-okhttp/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt:275">
P2: `text/plain` primitive handling claims character support but omits Kotlin `Char`, causing `Char` request bodies to throw.</violation>
</file>
<file name="samples/client/petstore/kotlin-allOf-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt">
<violation number="1" location="samples/client/petstore/kotlin-allOf-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt:275">
P2: `text/plain` body serialization excludes Kotlin `Char`, contradicting the stated support for characters and causing valid primitive payloads to throw.</violation>
</file>
<file name="samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt">
<violation number="1" location="samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt:275">
P2: `text/plain` primitive handling omits Kotlin `Char`, causing single-character bodies to throw `UnsupportedOperationException`.</violation>
</file>
<file name="samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt">
<violation number="1" location="samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt:275">
P2: `text/plain` primitive handling claims character support but rejects Kotlin `Char` at runtime.</violation>
</file>
<file name="samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt">
<violation number="1" location="samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt:275">
P2: `text/plain` primitive support claims to allow characters but omits Kotlin `Char`, causing valid single-character payloads to fail.</violation>
</file>
<file name="samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt">
<violation number="1" location="samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt:275">
P2: `text/plain` primitive-body handling omits Kotlin `Char`, causing runtime `UnsupportedOperationException` for single-character payloads.</violation>
</file>
<file name="samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt">
<violation number="1" location="samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt:275">
P2: `text/plain` primitive body handling omits Kotlin `Char`, so single-character payloads are rejected despite claiming character support.</violation>
</file>
<file name="samples/client/others/kotlin-jvm-okhttp-non-ascii-headers/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt">
<violation number="1" location="samples/client/others/kotlin-jvm-okhttp-non-ascii-headers/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt:275">
P2: `text/plain` primitive handling is incomplete: `Char` bodies are rejected because the new type checks omit `Char` even though the code claims to support characters.</violation>
</file>
<file name="samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt">
<violation number="1" location="samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt:275">
P2: `text/plain` primitive serialization omits Kotlin `Char`, causing runtime rejection despite claiming character support.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Member
|
thanks for the contribution, which has been merged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the
ApiClientfor OkHttp allows sending textual body payloads (MIME=text/plain) only for Strings, but it can be easily adapted to send primitive types too: any character sequence, numbers, and booleans.This small PR allows doing just that. If the content is not a primitive, then a suitable error is thrown instead.
PR checklist
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.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)@karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10) @dennisameling (2026/02)
Summary by cubic
Extend the Kotlin JVM OkHttp
ApiClientto supporttext/plainbodies from primitive values (Char/CharSequence, Number, Boolean via toString); non-primitives now error clearly, logic is consolidated into a singlewhen, and samples are regenerated.Written for commit 40b7d40. Summary will update on new commits.