Skip to content

[KOTLIN][BUG] Ktor deprecation for authentication #22808

@rlnt

Description

@rlnt

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

With Ktor 3.4.0, the extension function for String.encodeBase64 in io.ktor.util.Base64 was deprecated in favor of Base64.Default.encode() from the Kotlin standard library. To avoid errors in future updates of Ktor, the deprecated use should be replaced inside the generator of the authentication class.

openapi-generator version

7.19.0

OpenAPI declaration file content or url

OpenAPI Gradle plugin:

openApiGenerate {
    generatorName = "kotlin"
    inputSpec = openApiSpecFile.map { it.asFile.path }
    templateDir = "${rootDir.absolutePath}/.openapi/templates"
    outputDir = layout.buildDirectory.dir("generated/openapi")
        .map { it.asFile.path }
    typeMappings.put(
        "kotlinx.datetime.Instant",
        "kotlin.time.Instant"
    )
    importMappings.put(
        "kotlinx.datetime.Instant",
        "kotlin.time.Instant"
    )
    packageName = "${appId}.openapi"
    generateModelTests = false
    generateApiTests = false
    cleanupOutput = true
    configOptions = mapOf(
        "dateLibrary" to "kotlinx-datetime",
        // "enumPropertyNaming" to "UPPERCASE", currently bugged
        "library" to "multiplatform",
        "omitGradlePluginVersions" to "true",
        "omitGradleWrapper" to "true",
        // currently bugged, produces double serializable annotations, automatically set with "library" to "multiplatform"
        // https://github.com/OpenAPITools/openapi-generator/issues/18904
        // "serializationLibrary" to "kotlinx_serialization",
        "sourceFolder" to "commonMain/kotlin"
    )
}
Steps to reproduce
  • update Ktor to 3.4.0
  • generate API client with HTTP auth
  • see the deprecation warning in the generated auth class

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions