Skip to content

Commit 4e1607e

Browse files
committed
Run mvn clean/package, and regenerate samples
1 parent 50a7e12 commit 4e1607e

27 files changed

Lines changed: 378 additions & 81 deletions

File tree

  • 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

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
9898
* @see requestBody
9999
*/
100100
protected fun MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, file: File) {
101-
val partHeaders = headers.toMutableMap() +
101+
// Filter out Content-Type from headers as OkHttp requires it to be passed
102+
// separately via asRequestBody(mediaType), not in the headers map
103+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
102104
("Content-Disposition" to "form-data; name=\"$name\"; filename=\"${file.name}\"")
103105
val fileMediaType = guessContentTypeFromFile(file).toMediaTypeOrNull()
104106
addPart(
@@ -119,11 +121,20 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
119121
* @see requestBody
120122
*/
121123
protected fun <T> MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, obj: T?) {
122-
val partHeaders = headers.toMutableMap() +
124+
val partContentType = headers["Content-Type"]
125+
val partMediaType = partContentType?.toMediaTypeOrNull()
126+
// Filter out Content-Type from headers as OkHttp requires it to be passed
127+
// separately via toRequestBody(mediaType), not in the headers map
128+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
123129
("Content-Disposition" to "form-data; name=\"$name\"")
130+
val partBody = if (partContentType?.contains("json") == true) {
131+
Serializer.moshi.adapter(Any::class.java).toJson(obj)
132+
} else {
133+
parameterToString(obj)
134+
}
124135
addPart(
125136
partHeaders.toHeaders(),
126-
parameterToString(obj).toRequestBody(null)
137+
partBody.toRequestBody(partMediaType)
127138
)
128139
}
129140

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
9898
* @see requestBody
9999
*/
100100
protected fun MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, file: File) {
101-
val partHeaders = headers.toMutableMap() +
101+
// Filter out Content-Type from headers as OkHttp requires it to be passed
102+
// separately via asRequestBody(mediaType), not in the headers map
103+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
102104
("Content-Disposition" to "form-data; name=\"$name\"; filename=\"${file.name}\"")
103105
val fileMediaType = guessContentTypeFromFile(file).toMediaTypeOrNull()
104106
addPart(
@@ -119,11 +121,20 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
119121
* @see requestBody
120122
*/
121123
protected fun <T> MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, obj: T?) {
122-
val partHeaders = headers.toMutableMap() +
124+
val partContentType = headers["Content-Type"]
125+
val partMediaType = partContentType?.toMediaTypeOrNull()
126+
// Filter out Content-Type from headers as OkHttp requires it to be passed
127+
// separately via toRequestBody(mediaType), not in the headers map
128+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
123129
("Content-Disposition" to "form-data; name=\"$name\"")
130+
val partBody = if (partContentType?.contains("json") == true) {
131+
Serializer.moshi.adapter(Any::class.java).toJson(obj)
132+
} else {
133+
parameterToString(obj)
134+
}
124135
addPart(
125136
partHeaders.toHeaders(),
126-
parameterToString(obj).toRequestBody(null)
137+
partBody.toRequestBody(partMediaType)
127138
)
128139
}
129140

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
9898
* @see requestBody
9999
*/
100100
protected fun MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, file: File) {
101-
val partHeaders = headers.toMutableMap() +
101+
// Filter out Content-Type from headers as OkHttp requires it to be passed
102+
// separately via asRequestBody(mediaType), not in the headers map
103+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
102104
("Content-Disposition" to "form-data; name=\"$name\"; filename=\"${file.name}\"")
103105
val fileMediaType = guessContentTypeFromFile(file).toMediaTypeOrNull()
104106
addPart(
@@ -119,11 +121,20 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
119121
* @see requestBody
120122
*/
121123
protected fun <T> MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, obj: T?) {
122-
val partHeaders = headers.toMutableMap() +
124+
val partContentType = headers["Content-Type"]
125+
val partMediaType = partContentType?.toMediaTypeOrNull()
126+
// Filter out Content-Type from headers as OkHttp requires it to be passed
127+
// separately via toRequestBody(mediaType), not in the headers map
128+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
123129
("Content-Disposition" to "form-data; name=\"$name\"")
130+
val partBody = if (partContentType?.contains("json") == true) {
131+
Serializer.moshi.adapter(Any::class.java).toJson(obj)
132+
} else {
133+
parameterToString(obj)
134+
}
124135
addPart(
125136
partHeaders.toHeaders(),
126-
parameterToString(obj).toRequestBody(null)
137+
partBody.toRequestBody(partMediaType)
127138
)
128139
}
129140

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
9898
* @see requestBody
9999
*/
100100
protected fun MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, file: File) {
101-
val partHeaders = headers.toMutableMap() +
101+
// Filter out Content-Type from headers as OkHttp requires it to be passed
102+
// separately via asRequestBody(mediaType), not in the headers map
103+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
102104
("Content-Disposition" to "form-data; name=\"$name\"; filename=\"${file.name}\"")
103105
val fileMediaType = guessContentTypeFromFile(file).toMediaTypeOrNull()
104106
addPart(
@@ -119,11 +121,20 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
119121
* @see requestBody
120122
*/
121123
protected fun <T> MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, obj: T?) {
122-
val partHeaders = headers.toMutableMap() +
124+
val partContentType = headers["Content-Type"]
125+
val partMediaType = partContentType?.toMediaTypeOrNull()
126+
// Filter out Content-Type from headers as OkHttp requires it to be passed
127+
// separately via toRequestBody(mediaType), not in the headers map
128+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
123129
("Content-Disposition" to "form-data; name=\"$name\"")
130+
val partBody = if (partContentType?.contains("json") == true) {
131+
Serializer.moshi.adapter(Any::class.java).toJson(obj)
132+
} else {
133+
parameterToString(obj)
134+
}
124135
addPart(
125136
partHeaders.toHeaders(),
126-
parameterToString(obj).toRequestBody(null)
137+
partBody.toRequestBody(partMediaType)
127138
)
128139
}
129140

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
9898
* @see requestBody
9999
*/
100100
protected fun MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, file: File) {
101-
val partHeaders = headers.toMutableMap() +
101+
// Filter out Content-Type from headers as OkHttp requires it to be passed
102+
// separately via asRequestBody(mediaType), not in the headers map
103+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
102104
("Content-Disposition" to "form-data; name=\"$name\"; filename=\"${file.name}\"")
103105
val fileMediaType = guessContentTypeFromFile(file).toMediaTypeOrNull()
104106
addPart(
@@ -119,11 +121,20 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
119121
* @see requestBody
120122
*/
121123
protected fun <T> MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, obj: T?) {
122-
val partHeaders = headers.toMutableMap() +
124+
val partContentType = headers["Content-Type"]
125+
val partMediaType = partContentType?.toMediaTypeOrNull()
126+
// Filter out Content-Type from headers as OkHttp requires it to be passed
127+
// separately via toRequestBody(mediaType), not in the headers map
128+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
123129
("Content-Disposition" to "form-data; name=\"$name\"")
130+
val partBody = if (partContentType?.contains("json") == true) {
131+
Serializer.moshi.adapter(Any::class.java).toJson(obj)
132+
} else {
133+
parameterToString(obj)
134+
}
124135
addPart(
125136
partHeaders.toHeaders(),
126-
parameterToString(obj).toRequestBody(null)
137+
partBody.toRequestBody(partMediaType)
127138
)
128139
}
129140

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
9999
* @see requestBody
100100
*/
101101
protected fun MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, file: File) {
102-
val partHeaders = headers.toMutableMap() +
102+
// Filter out Content-Type from headers as OkHttp requires it to be passed
103+
// separately via asRequestBody(mediaType), not in the headers map
104+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
103105
("Content-Disposition" to "form-data; name=\"$name\"; filename=\"${file.name}\"")
104106
val fileMediaType = guessContentTypeFromFile(file).toMediaTypeOrNull()
105107
addPart(
@@ -120,11 +122,20 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
120122
* @see requestBody
121123
*/
122124
protected fun <T> MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, obj: T?) {
123-
val partHeaders = headers.toMutableMap() +
125+
val partContentType = headers["Content-Type"]
126+
val partMediaType = partContentType?.toMediaTypeOrNull()
127+
// Filter out Content-Type from headers as OkHttp requires it to be passed
128+
// separately via toRequestBody(mediaType), not in the headers map
129+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
124130
("Content-Disposition" to "form-data; name=\"$name\"")
131+
val partBody = if (partContentType?.contains("json") == true) {
132+
Serializer.kotlinxSerializationJson.encodeToString(obj)
133+
} else {
134+
parameterToString(obj)
135+
}
125136
addPart(
126137
partHeaders.toHeaders(),
127-
parameterToString(obj).toRequestBody(null)
138+
partBody.toRequestBody(partMediaType)
128139
)
129140
}
130141

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
9898
* @see requestBody
9999
*/
100100
protected fun MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, file: File) {
101-
val partHeaders = headers.toMutableMap() +
101+
// Filter out Content-Type from headers as OkHttp requires it to be passed
102+
// separately via asRequestBody(mediaType), not in the headers map
103+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
102104
("Content-Disposition" to "form-data; name=\"$name\"; filename=\"${file.name}\"")
103105
val fileMediaType = guessContentTypeFromFile(file).toMediaTypeOrNull()
104106
addPart(
@@ -119,11 +121,20 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
119121
* @see requestBody
120122
*/
121123
protected fun <T> MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, obj: T?) {
122-
val partHeaders = headers.toMutableMap() +
124+
val partContentType = headers["Content-Type"]
125+
val partMediaType = partContentType?.toMediaTypeOrNull()
126+
// Filter out Content-Type from headers as OkHttp requires it to be passed
127+
// separately via toRequestBody(mediaType), not in the headers map
128+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
123129
("Content-Disposition" to "form-data; name=\"$name\"")
130+
val partBody = if (partContentType?.contains("json") == true) {
131+
Serializer.moshi.adapter(Any::class.java).toJson(obj)
132+
} else {
133+
parameterToString(obj)
134+
}
124135
addPart(
125136
partHeaders.toHeaders(),
126-
parameterToString(obj).toRequestBody(null)
137+
partBody.toRequestBody(partMediaType)
127138
)
128139
}
129140

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
9898
* @see requestBody
9999
*/
100100
protected fun MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, file: File) {
101-
val partHeaders = headers.toMutableMap() +
101+
// Filter out Content-Type from headers as OkHttp requires it to be passed
102+
// separately via asRequestBody(mediaType), not in the headers map
103+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
102104
("Content-Disposition" to "form-data; name=\"$name\"; filename=\"${file.name}\"")
103105
val fileMediaType = guessContentTypeFromFile(file).toMediaTypeOrNull()
104106
addPart(
@@ -119,11 +121,20 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
119121
* @see requestBody
120122
*/
121123
protected fun <T> MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, obj: T?) {
122-
val partHeaders = headers.toMutableMap() +
124+
val partContentType = headers["Content-Type"]
125+
val partMediaType = partContentType?.toMediaTypeOrNull()
126+
// Filter out Content-Type from headers as OkHttp requires it to be passed
127+
// separately via toRequestBody(mediaType), not in the headers map
128+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
123129
("Content-Disposition" to "form-data; name=\"$name\"")
130+
val partBody = if (partContentType?.contains("json") == true) {
131+
Serializer.moshi.adapter(Any::class.java).toJson(obj)
132+
} else {
133+
parameterToString(obj)
134+
}
124135
addPart(
125136
partHeaders.toHeaders(),
126-
parameterToString(obj).toRequestBody(null)
137+
partBody.toRequestBody(partMediaType)
127138
)
128139
}
129140

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
9898
* @see requestBody
9999
*/
100100
protected fun MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, file: File) {
101-
val partHeaders = headers.toMutableMap() +
101+
// Filter out Content-Type from headers as OkHttp requires it to be passed
102+
// separately via asRequestBody(mediaType), not in the headers map
103+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
102104
("Content-Disposition" to "form-data; name=\"$name\"; filename=\"${file.name}\"")
103105
val fileMediaType = guessContentTypeFromFile(file).toMediaTypeOrNull()
104106
addPart(
@@ -119,11 +121,20 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
119121
* @see requestBody
120122
*/
121123
protected fun <T> MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, obj: T?) {
122-
val partHeaders = headers.toMutableMap() +
124+
val partContentType = headers["Content-Type"]
125+
val partMediaType = partContentType?.toMediaTypeOrNull()
126+
// Filter out Content-Type from headers as OkHttp requires it to be passed
127+
// separately via toRequestBody(mediaType), not in the headers map
128+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
123129
("Content-Disposition" to "form-data; name=\"$name\"")
130+
val partBody = if (partContentType?.contains("json") == true) {
131+
Serializer.moshi.adapter(Any::class.java).toJson(obj)
132+
} else {
133+
parameterToString(obj)
134+
}
124135
addPart(
125136
partHeaders.toHeaders(),
126-
parameterToString(obj).toRequestBody(null)
137+
partBody.toRequestBody(partMediaType)
127138
)
128139
}
129140

samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
9898
* @see requestBody
9999
*/
100100
protected fun MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, file: File) {
101-
val partHeaders = headers.toMutableMap() +
101+
// Filter out Content-Type from headers as OkHttp requires it to be passed
102+
// separately via asRequestBody(mediaType), not in the headers map
103+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
102104
("Content-Disposition" to "form-data; name=\"$name\"; filename=\"${file.name}\"")
103105
val fileMediaType = guessContentTypeFromFile(file).toMediaTypeOrNull()
104106
addPart(
@@ -119,11 +121,20 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
119121
* @see requestBody
120122
*/
121123
protected fun <T> MultipartBody.Builder.addPartToMultiPart(name: String, headers: Map<String, String>, obj: T?) {
122-
val partHeaders = headers.toMutableMap() +
124+
val partContentType = headers["Content-Type"]
125+
val partMediaType = partContentType?.toMediaTypeOrNull()
126+
// Filter out Content-Type from headers as OkHttp requires it to be passed
127+
// separately via toRequestBody(mediaType), not in the headers map
128+
val partHeaders = headers.filterKeys { it != "Content-Type" }.toMutableMap() +
123129
("Content-Disposition" to "form-data; name=\"$name\"")
130+
val partBody = if (partContentType?.contains("json") == true) {
131+
Serializer.moshi.adapter(Any::class.java).toJson(obj)
132+
} else {
133+
parameterToString(obj)
134+
}
124135
addPart(
125136
partHeaders.toHeaders(),
126-
parameterToString(obj).toRequestBody(null)
137+
partBody.toRequestBody(partMediaType)
127138
)
128139
}
129140

0 commit comments

Comments
 (0)