From 9acac9f182817ea4cbabbe3cd69eb988c10e5e63 Mon Sep 17 00:00:00 2001 From: rlnt Date: Tue, 24 Mar 2026 09:31:30 +0100 Subject: [PATCH 1/2] replace deprecated Ktor base64 encoding with Kotlin std library call fixes #22808 --- .../libraries/jvm-ktor/auth/HttpBasicAuth.kt.mustache | 4 ++-- .../libraries/multiplatform/auth/HttpBasicAuth.kt.mustache | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/auth/HttpBasicAuth.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/auth/HttpBasicAuth.kt.mustache index 0e3dba003ef0..c18b30352f05 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/auth/HttpBasicAuth.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/auth/HttpBasicAuth.kt.mustache @@ -1,6 +1,6 @@ package {{packageName}}.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 {{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}class HttpBasicAuth : Authentication { {{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}var username: String? = null @@ -9,7 +9,7 @@ import io.ktor.util.encodeBase64 override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } } diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/auth/HttpBasicAuth.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/auth/HttpBasicAuth.kt.mustache index 0e3dba003ef0..c18b30352f05 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/auth/HttpBasicAuth.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/auth/HttpBasicAuth.kt.mustache @@ -1,6 +1,6 @@ package {{packageName}}.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 {{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}class HttpBasicAuth : Authentication { {{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}var username: String? = null @@ -9,7 +9,7 @@ import io.ktor.util.encodeBase64 override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } } From 369e6ea858526bba4d55027da4f3220d0e51f155 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 25 Mar 2026 14:18:53 +0800 Subject: [PATCH 2/2] update kotlin samples --- .../kotlin/org/openapitools/client/auth/HttpBasicAuth.kt | 4 ++-- .../kotlin/org/openapitools/client/auth/HttpBasicAuth.kt | 4 ++-- .../kotlin/org/openapitools/client/auth/HttpBasicAuth.kt | 4 ++-- .../kotlin/org/openapitools/client/auth/HttpBasicAuth.kt | 4 ++-- .../main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt | 4 ++-- .../main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt | 4 ++-- .../main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt | 4 ++-- .../kotlin/org/openapitools/client/auth/HttpBasicAuth.kt | 4 ++-- .../kotlin/org/openapitools/client/auth/HttpBasicAuth.kt | 4 ++-- .../kotlin/org/openapitools/client/auth/HttpBasicAuth.kt | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt b/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt index 7c4761bbd6f7..b4aecdc99658 100644 --- a/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt +++ b/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt @@ -1,6 +1,6 @@ package org.openapitools.client.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 class HttpBasicAuth : Authentication { var username: String? = null @@ -9,7 +9,7 @@ class HttpBasicAuth : Authentication { override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } } diff --git a/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt b/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt index 7c4761bbd6f7..b4aecdc99658 100644 --- a/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt +++ b/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt @@ -1,6 +1,6 @@ package org.openapitools.client.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 class HttpBasicAuth : Authentication { var username: String? = null @@ -9,7 +9,7 @@ class HttpBasicAuth : Authentication { override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } } diff --git a/samples/client/petstore/kotlin-default-values-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt b/samples/client/petstore/kotlin-default-values-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt index 7c4761bbd6f7..b4aecdc99658 100644 --- a/samples/client/petstore/kotlin-default-values-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt +++ b/samples/client/petstore/kotlin-default-values-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt @@ -1,6 +1,6 @@ package org.openapitools.client.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 class HttpBasicAuth : Authentication { var username: String? = null @@ -9,7 +9,7 @@ class HttpBasicAuth : Authentication { override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } } diff --git a/samples/client/petstore/kotlin-enum-integers-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt b/samples/client/petstore/kotlin-enum-integers-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt index 7c4761bbd6f7..b4aecdc99658 100644 --- a/samples/client/petstore/kotlin-enum-integers-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt +++ b/samples/client/petstore/kotlin-enum-integers-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt @@ -1,6 +1,6 @@ package org.openapitools.client.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 class HttpBasicAuth : Authentication { var username: String? = null @@ -9,7 +9,7 @@ class HttpBasicAuth : Authentication { override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } } diff --git a/samples/client/petstore/kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt b/samples/client/petstore/kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt index 7c4761bbd6f7..b4aecdc99658 100644 --- a/samples/client/petstore/kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt +++ b/samples/client/petstore/kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt @@ -1,6 +1,6 @@ package org.openapitools.client.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 class HttpBasicAuth : Authentication { var username: String? = null @@ -9,7 +9,7 @@ class HttpBasicAuth : Authentication { override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } } diff --git a/samples/client/petstore/kotlin-jvm-ktor-jackson/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt b/samples/client/petstore/kotlin-jvm-ktor-jackson/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt index 7c4761bbd6f7..b4aecdc99658 100644 --- a/samples/client/petstore/kotlin-jvm-ktor-jackson/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt +++ b/samples/client/petstore/kotlin-jvm-ktor-jackson/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt @@ -1,6 +1,6 @@ package org.openapitools.client.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 class HttpBasicAuth : Authentication { var username: String? = null @@ -9,7 +9,7 @@ class HttpBasicAuth : Authentication { override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } } diff --git a/samples/client/petstore/kotlin-jvm-ktor-kotlinx_serialization/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt b/samples/client/petstore/kotlin-jvm-ktor-kotlinx_serialization/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt index 7c4761bbd6f7..b4aecdc99658 100644 --- a/samples/client/petstore/kotlin-jvm-ktor-kotlinx_serialization/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt +++ b/samples/client/petstore/kotlin-jvm-ktor-kotlinx_serialization/src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt @@ -1,6 +1,6 @@ package org.openapitools.client.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 class HttpBasicAuth : Authentication { var username: String? = null @@ -9,7 +9,7 @@ class HttpBasicAuth : Authentication { override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } } diff --git a/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt b/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt index 7c4761bbd6f7..b4aecdc99658 100644 --- a/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt +++ b/samples/client/petstore/kotlin-multiplatform-allOf-discriminator/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt @@ -1,6 +1,6 @@ package org.openapitools.client.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 class HttpBasicAuth : Authentication { var username: String? = null @@ -9,7 +9,7 @@ class HttpBasicAuth : Authentication { override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } } diff --git a/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt b/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt index 7c4761bbd6f7..b4aecdc99658 100644 --- a/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt +++ b/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt @@ -1,6 +1,6 @@ package org.openapitools.client.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 class HttpBasicAuth : Authentication { var username: String? = null @@ -9,7 +9,7 @@ class HttpBasicAuth : Authentication { override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } } diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt index 7c4761bbd6f7..b4aecdc99658 100644 --- a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt @@ -1,6 +1,6 @@ package org.openapitools.client.auth -import io.ktor.util.encodeBase64 +import kotlin.io.encoding.Base64 class HttpBasicAuth : Authentication { var username: String? = null @@ -9,7 +9,7 @@ class HttpBasicAuth : Authentication { override fun apply(query: MutableMap>, headers: MutableMap) { if (username == null && password == null) return val str = (username ?: "") + ":" + (password ?: "") - val auth = str.encodeBase64() + val auth = Base64.encode(str.encodeToByteArray()) headers["Authorization"] = "Basic $auth" } }