File tree Expand file tree Collapse file tree 9 files changed +41
-0
lines changed
modules/openapi-generator/src/main/resources/kotlin-client/libraries
multiplatform/infrastructure
kotlin-array-simple-string-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure
kotlin-bigdecimal-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure
kotlin-default-values-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure
kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/infrastructure
kotlin-jvm-ktor-jackson/src/main/kotlin/org/openapitools/client/infrastructure
kotlin-jvm-ktor-kotlinx_serialization/src/main/kotlin/org/openapitools/client/infrastructure
kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure Expand file tree Collapse file tree 9 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import io.ktor.client.request.request
13
13
import io.ktor.client.request.setBody
14
14
import io.ktor.client.statement.HttpResponse
15
15
import io.ktor.http.contentType
16
+ import io.ktor.http.ContentType
16
17
import io.ktor.http.HttpHeaders
17
18
import io.ktor.http.HttpMethod
18
19
import io.ktor.http.Parameters
@@ -196,6 +197,9 @@ import {{packageName}}.auth.*
196
197
this.method = requestConfig.method.httpMethod
197
198
headers.filter { header -> ! UNSAFE_HEADERS.contains(header.key) } .forEach { header -> this.header(header.key, header.value) }
198
199
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
200
+ val contentType = (requestConfig.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) }
201
+ ?: ContentType.Application.Json)
202
+ this.contentType(contentType)
199
203
setBody(body)
200
204
}
201
205
}
Original file line number Diff line number Diff line change @@ -10,9 +10,11 @@ import io.ktor.client.request.forms.MultiPartFormDataContent
10
10
import io.ktor.client.request.header
11
11
import io.ktor.client.request.parameter
12
12
import io.ktor.client.statement.HttpResponse
13
+ import io.ktor.http.ContentType
13
14
import io.ktor.serialization.kotlinx.json.json
14
15
import io.ktor.http.*
15
16
import io.ktor.http.content.PartData
17
+ import io.ktor.http.contentType
16
18
import kotlin.Unit
17
19
import kotlinx.serialization.json.Json
18
20
@@ -165,6 +167,9 @@ import {{packageName}}.auth.*
165
167
this.method = requestConfig.method.httpMethod
166
168
headers.filter { header -> ! UNSAFE_HEADERS.contains(header.key) } .forEach { header -> this.header(header.key, header.value) }
167
169
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
170
+ val contentType = (requestConfig.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) }
171
+ ?: ContentType.Application.Json)
172
+ this.contentType(contentType)
168
173
this.setBody(body)
169
174
}
170
175
}
Original file line number Diff line number Diff line change @@ -10,9 +10,11 @@ import io.ktor.client.request.forms.MultiPartFormDataContent
10
10
import io.ktor.client.request.header
11
11
import io.ktor.client.request.parameter
12
12
import io.ktor.client.statement.HttpResponse
13
+ import io.ktor.http.ContentType
13
14
import io.ktor.serialization.kotlinx.json.json
14
15
import io.ktor.http.*
15
16
import io.ktor.http.content.PartData
17
+ import io.ktor.http.contentType
16
18
import kotlin.Unit
17
19
import kotlinx.serialization.json.Json
18
20
@@ -154,6 +156,9 @@ open class ApiClient(
154
156
this .method = requestConfig.method.httpMethod
155
157
headers.filter { header -> ! UNSAFE_HEADERS .contains(header.key) }.forEach { header -> this .header(header.key, header.value) }
156
158
if (requestConfig.method in listOf (RequestMethod .PUT , RequestMethod .POST , RequestMethod .PATCH )) {
159
+ val contentType = (requestConfig.headers[HttpHeaders .ContentType ]?.let { ContentType .parse(it) }
160
+ ? : ContentType .Application .Json )
161
+ this .contentType(contentType)
157
162
this .setBody(body)
158
163
}
159
164
}
Original file line number Diff line number Diff line change @@ -10,9 +10,11 @@ import io.ktor.client.request.forms.MultiPartFormDataContent
10
10
import io.ktor.client.request.header
11
11
import io.ktor.client.request.parameter
12
12
import io.ktor.client.statement.HttpResponse
13
+ import io.ktor.http.ContentType
13
14
import io.ktor.serialization.kotlinx.json.json
14
15
import io.ktor.http.*
15
16
import io.ktor.http.content.PartData
17
+ import io.ktor.http.contentType
16
18
import kotlin.Unit
17
19
import kotlinx.serialization.json.Json
18
20
@@ -154,6 +156,9 @@ open class ApiClient(
154
156
this .method = requestConfig.method.httpMethod
155
157
headers.filter { header -> ! UNSAFE_HEADERS .contains(header.key) }.forEach { header -> this .header(header.key, header.value) }
156
158
if (requestConfig.method in listOf (RequestMethod .PUT , RequestMethod .POST , RequestMethod .PATCH )) {
159
+ val contentType = (requestConfig.headers[HttpHeaders .ContentType ]?.let { ContentType .parse(it) }
160
+ ? : ContentType .Application .Json )
161
+ this .contentType(contentType)
157
162
this .setBody(body)
158
163
}
159
164
}
Original file line number Diff line number Diff line change @@ -10,9 +10,11 @@ import io.ktor.client.request.forms.MultiPartFormDataContent
10
10
import io.ktor.client.request.header
11
11
import io.ktor.client.request.parameter
12
12
import io.ktor.client.statement.HttpResponse
13
+ import io.ktor.http.ContentType
13
14
import io.ktor.serialization.kotlinx.json.json
14
15
import io.ktor.http.*
15
16
import io.ktor.http.content.PartData
17
+ import io.ktor.http.contentType
16
18
import kotlin.Unit
17
19
import kotlinx.serialization.json.Json
18
20
@@ -154,6 +156,9 @@ open class ApiClient(
154
156
this .method = requestConfig.method.httpMethod
155
157
headers.filter { header -> ! UNSAFE_HEADERS .contains(header.key) }.forEach { header -> this .header(header.key, header.value) }
156
158
if (requestConfig.method in listOf (RequestMethod .PUT , RequestMethod .POST , RequestMethod .PATCH )) {
159
+ val contentType = (requestConfig.headers[HttpHeaders .ContentType ]?.let { ContentType .parse(it) }
160
+ ? : ContentType .Application .Json )
161
+ this .contentType(contentType)
157
162
this .setBody(body)
158
163
}
159
164
}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import io.ktor.client.request.request
13
13
import io.ktor.client.request.setBody
14
14
import io.ktor.client.statement.HttpResponse
15
15
import io.ktor.http.contentType
16
+ import io.ktor.http.ContentType
16
17
import io.ktor.http.HttpHeaders
17
18
import io.ktor.http.HttpMethod
18
19
import io.ktor.http.Parameters
@@ -156,6 +157,9 @@ open class ApiClient(
156
157
this .method = requestConfig.method.httpMethod
157
158
headers.filter { header -> ! UNSAFE_HEADERS .contains(header.key) }.forEach { header -> this .header(header.key, header.value) }
158
159
if (requestConfig.method in listOf (RequestMethod .PUT , RequestMethod .POST , RequestMethod .PATCH )) {
160
+ val contentType = (requestConfig.headers[HttpHeaders .ContentType ]?.let { ContentType .parse(it) }
161
+ ? : ContentType .Application .Json )
162
+ this .contentType(contentType)
159
163
setBody(body)
160
164
}
161
165
}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import io.ktor.client.request.request
13
13
import io.ktor.client.request.setBody
14
14
import io.ktor.client.statement.HttpResponse
15
15
import io.ktor.http.contentType
16
+ import io.ktor.http.ContentType
16
17
import io.ktor.http.HttpHeaders
17
18
import io.ktor.http.HttpMethod
18
19
import io.ktor.http.Parameters
@@ -164,6 +165,9 @@ open class ApiClient(
164
165
this .method = requestConfig.method.httpMethod
165
166
headers.filter { header -> ! UNSAFE_HEADERS .contains(header.key) }.forEach { header -> this .header(header.key, header.value) }
166
167
if (requestConfig.method in listOf (RequestMethod .PUT , RequestMethod .POST , RequestMethod .PATCH )) {
168
+ val contentType = (requestConfig.headers[HttpHeaders .ContentType ]?.let { ContentType .parse(it) }
169
+ ? : ContentType .Application .Json )
170
+ this .contentType(contentType)
167
171
setBody(body)
168
172
}
169
173
}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import io.ktor.client.request.request
13
13
import io.ktor.client.request.setBody
14
14
import io.ktor.client.statement.HttpResponse
15
15
import io.ktor.http.contentType
16
+ import io.ktor.http.ContentType
16
17
import io.ktor.http.HttpHeaders
17
18
import io.ktor.http.HttpMethod
18
19
import io.ktor.http.Parameters
@@ -147,6 +148,9 @@ open class ApiClient(
147
148
this .method = requestConfig.method.httpMethod
148
149
headers.filter { header -> ! UNSAFE_HEADERS .contains(header.key) }.forEach { header -> this .header(header.key, header.value) }
149
150
if (requestConfig.method in listOf (RequestMethod .PUT , RequestMethod .POST , RequestMethod .PATCH )) {
151
+ val contentType = (requestConfig.headers[HttpHeaders .ContentType ]?.let { ContentType .parse(it) }
152
+ ? : ContentType .Application .Json )
153
+ this .contentType(contentType)
150
154
setBody(body)
151
155
}
152
156
}
Original file line number Diff line number Diff line change @@ -10,9 +10,11 @@ import io.ktor.client.request.forms.MultiPartFormDataContent
10
10
import io.ktor.client.request.header
11
11
import io.ktor.client.request.parameter
12
12
import io.ktor.client.statement.HttpResponse
13
+ import io.ktor.http.ContentType
13
14
import io.ktor.serialization.kotlinx.json.json
14
15
import io.ktor.http.*
15
16
import io.ktor.http.content.PartData
17
+ import io.ktor.http.contentType
16
18
import kotlin.Unit
17
19
import kotlinx.serialization.json.Json
18
20
@@ -158,6 +160,9 @@ open class ApiClient(
158
160
this .method = requestConfig.method.httpMethod
159
161
headers.filter { header -> ! UNSAFE_HEADERS .contains(header.key) }.forEach { header -> this .header(header.key, header.value) }
160
162
if (requestConfig.method in listOf (RequestMethod .PUT , RequestMethod .POST , RequestMethod .PATCH )) {
163
+ val contentType = (requestConfig.headers[HttpHeaders .ContentType ]?.let { ContentType .parse(it) }
164
+ ? : ContentType .Application .Json )
165
+ this .contentType(contentType)
161
166
this .setBody(body)
162
167
}
163
168
}
You can’t perform that action at this time.
0 commit comments