Skip to content

Commit 40b7d40

Browse files
committed
Accept also Char as a possible text body.
1 parent 34ac85a commit 40b7d40

28 files changed

Lines changed: 109 additions & 109 deletions

File tree

  • modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure
  • samples/client
    • echo_api/kotlin-jvm-okhttp/src/main/kotlin/org/openapitools/client/infrastructure
    • others
      • kotlin-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-jvm-okhttp-non-ascii-headers/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-jvm-okhttp-path-comments/src/main/kotlin/org/openapitools/client/infrastructure
    • petstore
      • kotlin-allOf-discriminator-kotlinx-serialization/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-allOf-discriminator/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-array-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-explicit/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure
      • kotlin/src/main/kotlin/org/openapitools/client/infrastructure

modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ import com.squareup.moshi.adapter
325325
mediaType == XML_MEDIA_TYPE -> throw UnsupportedOperationException("xml not currently supported.")
326326
mediaType == TEXT_MEDIA_TYPE -> {
327327
val textualContent = when (content) {
328-
is CharSequence -> content.toString()
328+
is Char, is CharSequence -> content.toString()
329329
is Number -> content.toString()
330330
is Boolean -> content.toString()
331331
else -> throw UnsupportedOperationException("requestBody currently only supports text body containing primitive types: characters, numbers, or booleans.")

samples/client/echo_api/kotlin-jvm-okhttp/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
271271
}
272272
mediaType == XML_MEDIA_TYPE -> throw UnsupportedOperationException("xml not currently supported.")
273273
mediaType == TEXT_MEDIA_TYPE -> {
274-
val textualContent = when {
275-
content is CharSequence -> content.toString()
276-
content is Number -> content.toString()
277-
content is Boolean -> content.toString()
274+
val textualContent = when (content) {
275+
is Char, is CharSequence -> content.toString()
276+
is Number -> content.toString()
277+
is Boolean -> content.toString()
278278
else -> throw UnsupportedOperationException("requestBody currently only supports text body containing primitive types: characters, numbers, or booleans.")
279279
}
280280
textualContent.toRequestBody(mediaType.toMediaTypeOrNull())

samples/client/others/kotlin-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
271271
}
272272
mediaType == XML_MEDIA_TYPE -> throw UnsupportedOperationException("xml not currently supported.")
273273
mediaType == TEXT_MEDIA_TYPE -> {
274-
val textualContent = when {
275-
content is CharSequence -> content.toString()
276-
content is Number -> content.toString()
277-
content is Boolean -> content.toString()
274+
val textualContent = when (content) {
275+
is Char, is CharSequence -> content.toString()
276+
is Number -> content.toString()
277+
is Boolean -> content.toString()
278278
else -> throw UnsupportedOperationException("requestBody currently only supports text body containing primitive types: characters, numbers, or booleans.")
279279
}
280280
textualContent.toRequestBody(mediaType.toMediaTypeOrNull())

samples/client/others/kotlin-jvm-okhttp-non-ascii-headers/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
271271
}
272272
mediaType == XML_MEDIA_TYPE -> throw UnsupportedOperationException("xml not currently supported.")
273273
mediaType == TEXT_MEDIA_TYPE -> {
274-
val textualContent = when {
275-
content is CharSequence -> content.toString()
276-
content is Number -> content.toString()
277-
content is Boolean -> content.toString()
274+
val textualContent = when (content) {
275+
is Char, is CharSequence -> content.toString()
276+
is Number -> content.toString()
277+
is Boolean -> content.toString()
278278
else -> throw UnsupportedOperationException("requestBody currently only supports text body containing primitive types: characters, numbers, or booleans.")
279279
}
280280
textualContent.toRequestBody(mediaType.toMediaTypeOrNull())

samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
271271
}
272272
mediaType == XML_MEDIA_TYPE -> throw UnsupportedOperationException("xml not currently supported.")
273273
mediaType == TEXT_MEDIA_TYPE -> {
274-
val textualContent = when {
275-
content is CharSequence -> content.toString()
276-
content is Number -> content.toString()
277-
content is Boolean -> content.toString()
274+
val textualContent = when (content) {
275+
is Char, is CharSequence -> content.toString()
276+
is Number -> content.toString()
277+
is Boolean -> content.toString()
278278
else -> throw UnsupportedOperationException("requestBody currently only supports text body containing primitive types: characters, numbers, or booleans.")
279279
}
280280
textualContent.toRequestBody(mediaType.toMediaTypeOrNull())

samples/client/others/kotlin-jvm-okhttp-path-comments/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
271271
}
272272
mediaType == XML_MEDIA_TYPE -> throw UnsupportedOperationException("xml not currently supported.")
273273
mediaType == TEXT_MEDIA_TYPE -> {
274-
val textualContent = when {
275-
content is CharSequence -> content.toString()
276-
content is Number -> content.toString()
277-
content is Boolean -> content.toString()
274+
val textualContent = when (content) {
275+
is Char, is CharSequence -> content.toString()
276+
is Number -> content.toString()
277+
is Boolean -> content.toString()
278278
else -> throw UnsupportedOperationException("requestBody currently only supports text body containing primitive types: characters, numbers, or booleans.")
279279
}
280280
textualContent.toRequestBody(mediaType.toMediaTypeOrNull())

samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,10 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
274274
}
275275
mediaType == XML_MEDIA_TYPE -> throw UnsupportedOperationException("xml not currently supported.")
276276
mediaType == TEXT_MEDIA_TYPE -> {
277-
val textualContent = when {
278-
content is CharSequence -> content.toString()
279-
content is Number -> content.toString()
280-
content is Boolean -> content.toString()
277+
val textualContent = when (content) {
278+
is Char, is CharSequence -> content.toString()
279+
is Number -> content.toString()
280+
is Boolean -> content.toString()
281281
else -> throw UnsupportedOperationException("requestBody currently only supports text body containing primitive types: characters, numbers, or booleans.")
282282
}
283283
textualContent.toRequestBody(mediaType.toMediaTypeOrNull())

samples/client/petstore/kotlin-allOf-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
271271
}
272272
mediaType == XML_MEDIA_TYPE -> throw UnsupportedOperationException("xml not currently supported.")
273273
mediaType == TEXT_MEDIA_TYPE -> {
274-
val textualContent = when {
275-
content is CharSequence -> content.toString()
276-
content is Number -> content.toString()
277-
content is Boolean -> content.toString()
274+
val textualContent = when (content) {
275+
is Char, is CharSequence -> content.toString()
276+
is Number -> content.toString()
277+
is Boolean -> content.toString()
278278
else -> throw UnsupportedOperationException("requestBody currently only supports text body containing primitive types: characters, numbers, or booleans.")
279279
}
280280
textualContent.toRequestBody(mediaType.toMediaTypeOrNull())

samples/client/petstore/kotlin-array-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
271271
}
272272
mediaType == XML_MEDIA_TYPE -> throw UnsupportedOperationException("xml not currently supported.")
273273
mediaType == TEXT_MEDIA_TYPE -> {
274-
val textualContent = when {
275-
content is CharSequence -> content.toString()
276-
content is Number -> content.toString()
277-
content is Boolean -> content.toString()
274+
val textualContent = when (content) {
275+
is Char, is CharSequence -> content.toString()
276+
is Number -> content.toString()
277+
is Boolean -> content.toString()
278278
else -> throw UnsupportedOperationException("requestBody currently only supports text body containing primitive types: characters, numbers, or booleans.")
279279
}
280280
textualContent.toRequestBody(mediaType.toMediaTypeOrNull())

samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
271271
}
272272
mediaType == XML_MEDIA_TYPE -> throw UnsupportedOperationException("xml not currently supported.")
273273
mediaType == TEXT_MEDIA_TYPE -> {
274-
val textualContent = when {
275-
content is CharSequence -> content.toString()
276-
content is Number -> content.toString()
277-
content is Boolean -> content.toString()
274+
val textualContent = when (content) {
275+
is Char, is CharSequence -> content.toString()
276+
is Number -> content.toString()
277+
is Boolean -> content.toString()
278278
else -> throw UnsupportedOperationException("requestBody currently only supports text body containing primitive types: characters, numbers, or booleans.")
279279
}
280280
textualContent.toRequestBody(mediaType.toMediaTypeOrNull())

0 commit comments

Comments
 (0)