diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache index d6dca22f5fc6..d805869f5ae0 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache @@ -20,8 +20,8 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ## Requires {{#jvm}} -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 {{/jvm}} {{#multiplatform}} * Kotlin 1.5.10 diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache index 5716f8656c32..e613a3d8f39d 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache @@ -11,7 +11,7 @@ wrapper { buildscript { ext.kotlin_version = '1.6.10' {{#jvm-ktor}} - ext.ktor_version = '2.0.3' + ext.ktor_version = '2.1.2' {{/jvm-ktor}} {{#jvm-retrofit2}} ext.retrofitVersion = '2.9.0' diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/infrastructure/ApiClient.kt.mustache index 51a0a5f504e5..301af9194f8c 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/infrastructure/ApiClient.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/infrastructure/ApiClient.kt.mustache @@ -12,6 +12,7 @@ import io.ktor.client.request.parameter import io.ktor.client.request.request import io.ktor.client.request.setBody import io.ktor.client.statement.HttpResponse +import io.ktor.http.contentType import io.ktor.http.HttpHeaders import io.ktor.http.HttpMethod import io.ktor.http.Parameters @@ -34,11 +35,6 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.core.util.DefaultIndenter import com.fasterxml.jackson.core.util.DefaultPrettyPrinter {{/jackson}} -import org.openapitools.client.auth.ApiKeyAuth -import org.openapitools.client.auth.Authentication -import org.openapitools.client.auth.HttpBasicAuth -import org.openapitools.client.auth.HttpBearerAuth -import org.openapitools.client.auth.OAuth import {{packageName}}.auth.* {{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient( @@ -111,7 +107,7 @@ import {{packageName}}.auth.* * @param username Username */ fun setUsername(username: String) { - val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? + val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? ?: throw Exception("No HTTP basic authentication configured") auth.username = username } @@ -122,7 +118,7 @@ import {{packageName}}.auth.* * @param password Password */ fun setPassword(password: String) { - val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? + val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? ?: throw Exception("No HTTP basic authentication configured") auth.password = password } @@ -134,7 +130,7 @@ import {{packageName}}.auth.* * @param paramName The name of the API key parameter, or null or set the first key. */ fun setApiKey(apiKey: String, paramName: String? = null) { - val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth? + val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth? ?: throw Exception("No API key authentication configured") auth.apiKey = apiKey } @@ -146,7 +142,7 @@ import {{packageName}}.auth.* * @param paramName The name of the API key parameter, or null or set the first key. */ fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) { - val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth? + val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth? ?: throw Exception("No API key authentication configured") auth.apiKeyPrefix = apiKeyPrefix } @@ -157,7 +153,7 @@ import {{packageName}}.auth.* * @param accessToken Access token */ fun setAccessToken(accessToken: String) { - val auth = authentications.values.firstOrNull { it is OAuth } as OAuth? + val auth = authentications?.values?.firstOrNull { it is OAuth } as OAuth? ?: throw Exception("No OAuth2 authentication configured") auth.accessToken = accessToken } @@ -168,7 +164,7 @@ import {{packageName}}.auth.* * @param bearerToken The bearer token. */ fun setBearerToken(bearerToken: String) { - val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth? + val auth = authentications?.values?.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth? ?: throw Exception("No Bearer authentication configured") auth.bearerToken = bearerToken } @@ -199,8 +195,9 @@ import {{packageName}}.auth.* } this.method = requestConfig.method.httpMethod headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) } - if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) + if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) { setBody(body) + } } } diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache index bc5d9b195081..bbed97d77aed 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache @@ -4,13 +4,13 @@ import io.ktor.client.HttpClient import io.ktor.client.HttpClientConfig import io.ktor.client.engine.HttpClientEngine import io.ktor.client.plugins.contentnegotiation.ContentNegotiation -import io.ktor.serialization.kotlinx.json.* import io.ktor.client.request.* import io.ktor.client.request.forms.FormDataContent import io.ktor.client.request.forms.MultiPartFormDataContent import io.ktor.client.request.header import io.ktor.client.request.parameter import io.ktor.client.statement.HttpResponse +import io.ktor.serialization.kotlinx.json.json import io.ktor.http.* import io.ktor.http.content.PartData import kotlin.Unit @@ -153,9 +153,9 @@ import {{packageName}}.auth.* } this.method = requestConfig.method.httpMethod headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) } - if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) + if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) { this.setBody(body) - + } } } diff --git a/samples/client/petstore/kotlin-allOff-discriminator/README.md b/samples/client/petstore/kotlin-allOff-discriminator/README.md index 6b1ed0fb3219..b8f74b274242 100644 --- a/samples/client/petstore/kotlin-allOff-discriminator/README.md +++ b/samples/client/petstore/kotlin-allOff-discriminator/README.md @@ -12,8 +12,8 @@ For more information, please visit [https://example.org](https://example.org) ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp3/README.md b/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp3/README.md index be47543f9633..49b1c94dab68 100644 --- a/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp3/README.md +++ b/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp3/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/README.md b/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/README.md index be47543f9633..49b1c94dab68 100644 --- a/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/README.md +++ b/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index fd07e4229d10..529ae1e4d05f 100644 --- a/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -4,13 +4,13 @@ import io.ktor.client.HttpClient import io.ktor.client.HttpClientConfig import io.ktor.client.engine.HttpClientEngine import io.ktor.client.plugins.contentnegotiation.ContentNegotiation -import io.ktor.serialization.kotlinx.json.* import io.ktor.client.request.* import io.ktor.client.request.forms.FormDataContent import io.ktor.client.request.forms.MultiPartFormDataContent import io.ktor.client.request.header import io.ktor.client.request.parameter import io.ktor.client.statement.HttpResponse +import io.ktor.serialization.kotlinx.json.json import io.ktor.http.* import io.ktor.http.content.PartData import kotlin.Unit @@ -142,9 +142,9 @@ open class ApiClient( } this.method = requestConfig.method.httpMethod headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) } - if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) + if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) { this.setBody(body) - + } } } diff --git a/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index fd07e4229d10..529ae1e4d05f 100644 --- a/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -4,13 +4,13 @@ import io.ktor.client.HttpClient import io.ktor.client.HttpClientConfig import io.ktor.client.engine.HttpClientEngine import io.ktor.client.plugins.contentnegotiation.ContentNegotiation -import io.ktor.serialization.kotlinx.json.* import io.ktor.client.request.* import io.ktor.client.request.forms.FormDataContent import io.ktor.client.request.forms.MultiPartFormDataContent import io.ktor.client.request.header import io.ktor.client.request.parameter import io.ktor.client.statement.HttpResponse +import io.ktor.serialization.kotlinx.json.json import io.ktor.http.* import io.ktor.http.content.PartData import kotlin.Unit @@ -142,9 +142,9 @@ open class ApiClient( } this.method = requestConfig.method.httpMethod headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) } - if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) + if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) { this.setBody(body) - + } } } diff --git a/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/README.md b/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/README.md index e1589aead68a..ccbdb1a4e4a9 100644 --- a/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/README.md +++ b/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-default-values-jvm-okhttp3/README.md b/samples/client/petstore/kotlin-default-values-jvm-okhttp3/README.md index 96bddb2ac986..c1b435ada57c 100644 --- a/samples/client/petstore/kotlin-default-values-jvm-okhttp3/README.md +++ b/samples/client/petstore/kotlin-default-values-jvm-okhttp3/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-default-values-jvm-okhttp4/README.md b/samples/client/petstore/kotlin-default-values-jvm-okhttp4/README.md index 96bddb2ac986..c1b435ada57c 100644 --- a/samples/client/petstore/kotlin-default-values-jvm-okhttp4/README.md +++ b/samples/client/petstore/kotlin-default-values-jvm-okhttp4/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-default-values-jvm-retrofit2/README.md b/samples/client/petstore/kotlin-default-values-jvm-retrofit2/README.md index 904786dd56bb..be72f0dfcf6c 100644 --- a/samples/client/petstore/kotlin-default-values-jvm-retrofit2/README.md +++ b/samples/client/petstore/kotlin-default-values-jvm-retrofit2/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-default-values-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-default-values-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index fd07e4229d10..529ae1e4d05f 100644 --- a/samples/client/petstore/kotlin-default-values-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-default-values-multiplatform/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -4,13 +4,13 @@ import io.ktor.client.HttpClient import io.ktor.client.HttpClientConfig import io.ktor.client.engine.HttpClientEngine import io.ktor.client.plugins.contentnegotiation.ContentNegotiation -import io.ktor.serialization.kotlinx.json.* import io.ktor.client.request.* import io.ktor.client.request.forms.FormDataContent import io.ktor.client.request.forms.MultiPartFormDataContent import io.ktor.client.request.header import io.ktor.client.request.parameter import io.ktor.client.statement.HttpResponse +import io.ktor.serialization.kotlinx.json.json import io.ktor.http.* import io.ktor.http.content.PartData import kotlin.Unit @@ -142,9 +142,9 @@ open class ApiClient( } this.method = requestConfig.method.httpMethod headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) } - if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) + if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) { this.setBody(body) - + } } } diff --git a/samples/client/petstore/kotlin-enum-default-value/README.md b/samples/client/petstore/kotlin-enum-default-value/README.md index df4685a2021a..665d73528702 100644 --- a/samples/client/petstore/kotlin-enum-default-value/README.md +++ b/samples/client/petstore/kotlin-enum-default-value/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-gson/README.md b/samples/client/petstore/kotlin-gson/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-gson/README.md +++ b/samples/client/petstore/kotlin-gson/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-jackson/README.md b/samples/client/petstore/kotlin-jackson/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-jackson/README.md +++ b/samples/client/petstore/kotlin-jackson/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-json-request-string/README.md b/samples/client/petstore/kotlin-json-request-string/README.md index eb18a4c21d8a..928a13052e77 100644 --- a/samples/client/petstore/kotlin-json-request-string/README.md +++ b/samples/client/petstore/kotlin-json-request-string/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-jvm-ktor-gson/README.md b/samples/client/petstore/kotlin-jvm-ktor-gson/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-jvm-ktor-gson/README.md +++ b/samples/client/petstore/kotlin-jvm-ktor-gson/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-jvm-ktor-gson/build.gradle b/samples/client/petstore/kotlin-jvm-ktor-gson/build.gradle index 0c3e6b64c92a..67441d77a6a5 100644 --- a/samples/client/petstore/kotlin-jvm-ktor-gson/build.gradle +++ b/samples/client/petstore/kotlin-jvm-ktor-gson/build.gradle @@ -8,7 +8,7 @@ wrapper { buildscript { ext.kotlin_version = '1.6.10' - ext.ktor_version = '2.0.3' + ext.ktor_version = '2.1.2' repositories { maven { url "https://repo1.maven.org/maven2" } diff --git a/samples/client/petstore/kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 5d6fc3af68b6..69c803dfbcf6 100644 --- a/samples/client/petstore/kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -12,6 +12,7 @@ import io.ktor.client.request.parameter import io.ktor.client.request.request import io.ktor.client.request.setBody import io.ktor.client.statement.HttpResponse +import io.ktor.http.contentType import io.ktor.http.HttpHeaders import io.ktor.http.HttpMethod import io.ktor.http.Parameters @@ -23,11 +24,6 @@ import io.ktor.http.takeFrom import io.ktor.serialization.gson.* import com.google.gson.GsonBuilder import java.text.DateFormat -import org.openapitools.client.auth.ApiKeyAuth -import org.openapitools.client.auth.Authentication -import org.openapitools.client.auth.HttpBasicAuth -import org.openapitools.client.auth.HttpBearerAuth -import org.openapitools.client.auth.OAuth import org.openapitools.client.auth.* open class ApiClient( @@ -71,7 +67,7 @@ open class ApiClient( * @param username Username */ fun setUsername(username: String) { - val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? + val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? ?: throw Exception("No HTTP basic authentication configured") auth.username = username } @@ -82,7 +78,7 @@ open class ApiClient( * @param password Password */ fun setPassword(password: String) { - val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? + val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? ?: throw Exception("No HTTP basic authentication configured") auth.password = password } @@ -94,7 +90,7 @@ open class ApiClient( * @param paramName The name of the API key parameter, or null or set the first key. */ fun setApiKey(apiKey: String, paramName: String? = null) { - val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth? + val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth? ?: throw Exception("No API key authentication configured") auth.apiKey = apiKey } @@ -106,7 +102,7 @@ open class ApiClient( * @param paramName The name of the API key parameter, or null or set the first key. */ fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) { - val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth? + val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth? ?: throw Exception("No API key authentication configured") auth.apiKeyPrefix = apiKeyPrefix } @@ -117,7 +113,7 @@ open class ApiClient( * @param accessToken Access token */ fun setAccessToken(accessToken: String) { - val auth = authentications.values.firstOrNull { it is OAuth } as OAuth? + val auth = authentications?.values?.firstOrNull { it is OAuth } as OAuth? ?: throw Exception("No OAuth2 authentication configured") auth.accessToken = accessToken } @@ -128,7 +124,7 @@ open class ApiClient( * @param bearerToken The bearer token. */ fun setBearerToken(bearerToken: String) { - val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth? + val auth = authentications?.values?.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth? ?: throw Exception("No Bearer authentication configured") auth.bearerToken = bearerToken } @@ -159,8 +155,9 @@ open class ApiClient( } this.method = requestConfig.method.httpMethod headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) } - if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) + if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) { setBody(body) + } } } diff --git a/samples/client/petstore/kotlin-jvm-ktor-jackson/README.md b/samples/client/petstore/kotlin-jvm-ktor-jackson/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-jvm-ktor-jackson/README.md +++ b/samples/client/petstore/kotlin-jvm-ktor-jackson/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-jvm-ktor-jackson/build.gradle b/samples/client/petstore/kotlin-jvm-ktor-jackson/build.gradle index febcd440b1e9..072128b1cecb 100644 --- a/samples/client/petstore/kotlin-jvm-ktor-jackson/build.gradle +++ b/samples/client/petstore/kotlin-jvm-ktor-jackson/build.gradle @@ -8,7 +8,7 @@ wrapper { buildscript { ext.kotlin_version = '1.6.10' - ext.ktor_version = '2.0.3' + ext.ktor_version = '2.1.2' repositories { maven { url "https://repo1.maven.org/maven2" } diff --git a/samples/client/petstore/kotlin-jvm-ktor-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-jvm-ktor-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index e21bccb90604..bb3a5290cf6e 100644 --- a/samples/client/petstore/kotlin-jvm-ktor-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-jvm-ktor-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -12,6 +12,7 @@ import io.ktor.client.request.parameter import io.ktor.client.request.request import io.ktor.client.request.setBody import io.ktor.client.statement.HttpResponse +import io.ktor.http.contentType import io.ktor.http.HttpHeaders import io.ktor.http.HttpMethod import io.ktor.http.Parameters @@ -27,11 +28,6 @@ import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.core.util.DefaultIndenter import com.fasterxml.jackson.core.util.DefaultPrettyPrinter -import org.openapitools.client.auth.ApiKeyAuth -import org.openapitools.client.auth.Authentication -import org.openapitools.client.auth.HttpBasicAuth -import org.openapitools.client.auth.HttpBearerAuth -import org.openapitools.client.auth.OAuth import org.openapitools.client.auth.* open class ApiClient( @@ -79,7 +75,7 @@ open class ApiClient( * @param username Username */ fun setUsername(username: String) { - val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? + val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? ?: throw Exception("No HTTP basic authentication configured") auth.username = username } @@ -90,7 +86,7 @@ open class ApiClient( * @param password Password */ fun setPassword(password: String) { - val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? + val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth? ?: throw Exception("No HTTP basic authentication configured") auth.password = password } @@ -102,7 +98,7 @@ open class ApiClient( * @param paramName The name of the API key parameter, or null or set the first key. */ fun setApiKey(apiKey: String, paramName: String? = null) { - val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth? + val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth? ?: throw Exception("No API key authentication configured") auth.apiKey = apiKey } @@ -114,7 +110,7 @@ open class ApiClient( * @param paramName The name of the API key parameter, or null or set the first key. */ fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) { - val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth? + val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth? ?: throw Exception("No API key authentication configured") auth.apiKeyPrefix = apiKeyPrefix } @@ -125,7 +121,7 @@ open class ApiClient( * @param accessToken Access token */ fun setAccessToken(accessToken: String) { - val auth = authentications.values.firstOrNull { it is OAuth } as OAuth? + val auth = authentications?.values?.firstOrNull { it is OAuth } as OAuth? ?: throw Exception("No OAuth2 authentication configured") auth.accessToken = accessToken } @@ -136,7 +132,7 @@ open class ApiClient( * @param bearerToken The bearer token. */ fun setBearerToken(bearerToken: String) { - val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth? + val auth = authentications?.values?.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth? ?: throw Exception("No Bearer authentication configured") auth.bearerToken = bearerToken } @@ -167,8 +163,9 @@ open class ApiClient( } this.method = requestConfig.method.httpMethod headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) } - if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) + if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) { setBody(body) + } } } diff --git a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/README.md b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/README.md +++ b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-modelMutable/README.md b/samples/client/petstore/kotlin-modelMutable/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-modelMutable/README.md +++ b/samples/client/petstore/kotlin-modelMutable/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-moshi-codegen/README.md b/samples/client/petstore/kotlin-moshi-codegen/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-moshi-codegen/README.md +++ b/samples/client/petstore/kotlin-moshi-codegen/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index dc660734191a..35e549b98296 100644 --- a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -4,13 +4,13 @@ import io.ktor.client.HttpClient import io.ktor.client.HttpClientConfig import io.ktor.client.engine.HttpClientEngine import io.ktor.client.plugins.contentnegotiation.ContentNegotiation -import io.ktor.serialization.kotlinx.json.* import io.ktor.client.request.* import io.ktor.client.request.forms.FormDataContent import io.ktor.client.request.forms.MultiPartFormDataContent import io.ktor.client.request.header import io.ktor.client.request.parameter import io.ktor.client.statement.HttpResponse +import io.ktor.serialization.kotlinx.json.json import io.ktor.http.* import io.ktor.http.content.PartData import kotlin.Unit @@ -146,9 +146,9 @@ open class ApiClient( } this.method = requestConfig.method.httpMethod headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) } - if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) + if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) { this.setBody(body) - + } } } diff --git a/samples/client/petstore/kotlin-nonpublic/README.md b/samples/client/petstore/kotlin-nonpublic/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-nonpublic/README.md +++ b/samples/client/petstore/kotlin-nonpublic/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-nullable/README.md b/samples/client/petstore/kotlin-nullable/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-nullable/README.md +++ b/samples/client/petstore/kotlin-nullable/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-okhttp3/README.md b/samples/client/petstore/kotlin-okhttp3/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-okhttp3/README.md +++ b/samples/client/petstore/kotlin-okhttp3/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-retrofit2-kotlinx_serialization/README.md b/samples/client/petstore/kotlin-retrofit2-kotlinx_serialization/README.md index 1bd530b89967..473c874b300b 100644 --- a/samples/client/petstore/kotlin-retrofit2-kotlinx_serialization/README.md +++ b/samples/client/petstore/kotlin-retrofit2-kotlinx_serialization/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-retrofit2-rx3/README.md b/samples/client/petstore/kotlin-retrofit2-rx3/README.md index 1bd530b89967..473c874b300b 100644 --- a/samples/client/petstore/kotlin-retrofit2-rx3/README.md +++ b/samples/client/petstore/kotlin-retrofit2-rx3/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-retrofit2/README.md b/samples/client/petstore/kotlin-retrofit2/README.md index 1bd530b89967..473c874b300b 100644 --- a/samples/client/petstore/kotlin-retrofit2/README.md +++ b/samples/client/petstore/kotlin-retrofit2/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-string/README.md b/samples/client/petstore/kotlin-string/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-string/README.md +++ b/samples/client/petstore/kotlin-string/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-threetenbp/README.md b/samples/client/petstore/kotlin-threetenbp/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin-threetenbp/README.md +++ b/samples/client/petstore/kotlin-threetenbp/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin-uppercase-enum/README.md b/samples/client/petstore/kotlin-uppercase-enum/README.md index 9b3bfe4e89ef..40a6b5fa1abb 100644 --- a/samples/client/petstore/kotlin-uppercase-enum/README.md +++ b/samples/client/petstore/kotlin-uppercase-enum/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build diff --git a/samples/client/petstore/kotlin/README.md b/samples/client/petstore/kotlin/README.md index e8336e9f36b1..e3f2108bfcdc 100644 --- a/samples/client/petstore/kotlin/README.md +++ b/samples/client/petstore/kotlin/README.md @@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat ## Requires -* Kotlin 1.4.30 -* Gradle 6.8.3 +* Kotlin 1.6.10 +* Gradle 7.5 ## Build