Skip to content

[BUG] [kotlin-client] kotlinx_serialization deserialization fails on unexpected/unknown keys #13013

Closed

Description

@kassim
Description

Deserialization of a response with an unexpected key leads to the following error

kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 282: Encountered an unknown key 'card'. Use 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys.

openapi-generator version

6.0.1

Generation Details

using kotlinx_serialization as serialization library. gradle build specifics:

openApiGenerate {
    generatorName.set("kotlin")
    configOptions.set(
        mapOf(
            "serializationLibrary" to "kotlinx_serialization"
        )
    )
}
Related issues/PRs

#9755 – same fix added to kotlin-multiplatform solution already

Suggest a fix

Add ignoreUnknownKeys = true to jvmJson at the bottom of
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache

Activity

  1. kassim commented on Jul 26, 2022

    @kassim
    ContributorAuthor

    fixed by #12930

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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