Skip to content

Commit ba3404b

Browse files
committed
[kotlin][client] keep body on DELETE requests
Allow request body on DELETE in kotlin-client multiplatform and jvm-ktor templates. RFC 9110 permits DELETE bodies; some APIs require them (e.g. bulk-delete payloads). Mirrors the existing PUT/POST/PATCH handling.
1 parent c22c0f5 commit ba3404b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ import {{packageName}}.auth.*
196196
}
197197
this.method = requestConfig.method.httpMethod
198198
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
199-
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
199+
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH, RequestMethod.DELETE)) {
200200
val contentType = (requestConfig.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) }
201201
?: ContentType.Application.Json)
202202
this.contentType(contentType)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ import {{packageName}}.auth.*
166166
}
167167
this.method = requestConfig.method.httpMethod
168168
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
169-
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
169+
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH, RequestMethod.DELETE)) {
170170
val contentType = (requestConfig.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) }
171171
?: ContentType.Application.Json)
172172
this.contentType(contentType)

0 commit comments

Comments
 (0)