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] Generated Serializer for ApiClient does not support BigDecimal #7196

Closed
nilskuhn opened this issue Aug 13, 2020 · 5 comments
Closed

Comments

@nilskuhn
Copy link

Description

Generating a Kotlin client for an API that uses BigDecimal in the model, the generated ApiClient doesn't work because the generated Moshi serializer does not have a type adapter for BigDecimal. Unfortunately, there is no way to inject the type adapter yourself.

openapi-generator version

4.3.1

Steps to reproduce

Any API with BigDecimal should demonstrate the problem. Generate Kotlin API and try to send message. I get exception:

java.lang.IllegalArgumentException: Platform class java.math.BigDecimal (with no annotations) requires explicit JsonAdapter to be registered
	at com.squareup.moshi.ClassJsonAdapter$1.create(ClassJsonAdapter.java:60) ~[moshi-1.8.0.jar:na]
	at com.squareup.moshi.Moshi.adapter(Moshi.java:137) ~[moshi-1.8.0.jar:na]

Suggest a fix

Add BigDecimal adapter here: com.kn.containerDashboard.backend.client.rgs.infrastructure.Serializer

@wing328
Copy link
Member

wing328 commented Aug 14, 2020

@nilskuhn thanks for reporting the issue. Do you mind filing a PR with the suggested fix?

@nilskuhn
Copy link
Author

Yes, I will try to find the time.

@zarr
Copy link

zarr commented Sep 30, 2020

Possible workaround

Set the serializationLibrary to jackson in the generator configuration as described in https://openapi-generator.tech/docs/generators/kotlin

@kuFEAR
Copy link
Contributor

kuFEAR commented Nov 22, 2020

Hi, I added BigDecimal/BigInteger in my fork kuFEAR@05bd4e1, I'll send it later to parent repo after merge another one pr

@codymikol
Copy link
Contributor

@kuFEAR did you ever send in a PR for this?

codymikol pushed a commit to codymikol/openapi-generator that referenced this issue Apr 12, 2021
this allows the kotlin client generator to support
BigDecimal values

Fixes OpenAPITools#7196
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants