Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kassim opened this issue Jul 25, 2022 · 1 comment

Comments

@kassim
Copy link
Contributor

kassim commented Jul 25, 2022

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

@kassim
Copy link
Contributor Author

kassim commented Jul 26, 2022

fixed by #12930

@kassim kassim closed this as completed Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant