File tree Expand file tree Collapse file tree 6 files changed +23
-0
lines changed
modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure
kotlin-array-simple-string-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure
kotlin-bigdecimal-default-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure
kotlin-default-values-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure
commonMain/kotlin/org/openapitools/client/infrastructure Expand file tree Collapse file tree 6 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import io.ktor.client.request.parameter
12
12
import io.ktor.client.statement.HttpResponse
13
13
import io.ktor.serialization.kotlinx.json.json
14
14
import io.ktor.http.*
15
+ import io.ktor.http.ContentType.Application
15
16
import io.ktor.http.content.PartData
16
17
import kotlin.Unit
17
18
import kotlinx.serialization.json.Json
@@ -154,6 +155,7 @@ import {{packageName}}.auth.*
154
155
this.method = requestConfig.method.httpMethod
155
156
headers.filter { header -> ! UNSAFE_HEADERS.contains(header.key) } .forEach { header -> this.header(header.key, header.value) }
156
157
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
158
+ this.contentType(Application.Json)
157
159
this.setBody(body)
158
160
}
159
161
}
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import io.ktor.client.request.parameter
12
12
import io.ktor.client.statement.HttpResponse
13
13
import io.ktor.serialization.kotlinx.json.json
14
14
import io.ktor.http.*
15
+ import io.ktor.http.ContentType.Application
15
16
import io.ktor.http.content.PartData
16
17
import kotlin.Unit
17
18
import kotlinx.serialization.json.Json
@@ -143,6 +144,7 @@ open class ApiClient(
143
144
this .method = requestConfig.method.httpMethod
144
145
headers.filter { header -> ! UNSAFE_HEADERS .contains(header.key) }.forEach { header -> this .header(header.key, header.value) }
145
146
if (requestConfig.method in listOf (RequestMethod .PUT , RequestMethod .POST , RequestMethod .PATCH )) {
147
+ this .contentType(Application .Json )
146
148
this .setBody(body)
147
149
}
148
150
}
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import io.ktor.client.request.parameter
12
12
import io.ktor.client.statement.HttpResponse
13
13
import io.ktor.serialization.kotlinx.json.json
14
14
import io.ktor.http.*
15
+ import io.ktor.http.ContentType.Application
15
16
import io.ktor.http.content.PartData
16
17
import kotlin.Unit
17
18
import kotlinx.serialization.json.Json
@@ -143,6 +144,7 @@ open class ApiClient(
143
144
this .method = requestConfig.method.httpMethod
144
145
headers.filter { header -> ! UNSAFE_HEADERS .contains(header.key) }.forEach { header -> this .header(header.key, header.value) }
145
146
if (requestConfig.method in listOf (RequestMethod .PUT , RequestMethod .POST , RequestMethod .PATCH )) {
147
+ this .contentType(Application .Json )
146
148
this .setBody(body)
147
149
}
148
150
}
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import io.ktor.client.request.parameter
12
12
import io.ktor.client.statement.HttpResponse
13
13
import io.ktor.serialization.kotlinx.json.json
14
14
import io.ktor.http.*
15
+ import io.ktor.http.ContentType.Application
15
16
import io.ktor.http.content.PartData
16
17
import kotlin.Unit
17
18
import kotlinx.serialization.json.Json
@@ -143,6 +144,7 @@ open class ApiClient(
143
144
this .method = requestConfig.method.httpMethod
144
145
headers.filter { header -> ! UNSAFE_HEADERS .contains(header.key) }.forEach { header -> this .header(header.key, header.value) }
145
146
if (requestConfig.method in listOf (RequestMethod .PUT , RequestMethod .POST , RequestMethod .PATCH )) {
147
+ this .contentType(Application .Json )
146
148
this .setBody(body)
147
149
}
148
150
}
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import io.ktor.client.request.parameter
12
12
import io.ktor.client.statement.HttpResponse
13
13
import io.ktor.serialization.kotlinx.json.json
14
14
import io.ktor.http.*
15
+ import io.ktor.http.ContentType.Application
15
16
import io.ktor.http.content.PartData
16
17
import kotlin.Unit
17
18
import kotlinx.serialization.json.Json
@@ -147,6 +148,7 @@ 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
+ this .contentType(Application .Json )
150
152
this .setBody(body)
151
153
}
152
154
}
Original file line number Diff line number Diff line change
1
+ package util
2
+
3
+ import org.junit.Test
4
+ import org.openapitools.client.apis.PetApi
5
+ import org.openapitools.client.models.Pet
6
+
7
+ class PetStoreTest {
8
+ @Test
9
+ fun addPet () = runTest {
10
+ val mainApi = PetApi ()
11
+ println (mainApi.addPet(Pet (" TestPet" , emptyList())).body())
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments