Description
Description
I am working on producing types from schema files using an openapi generator with the kotlinx_serialization library. This works flawlessly for 60ish types / data classes. But when serializing a Polygon schema with a Point inside, the kotlinx serializer does not add an @contextual tag to allow for BigDecimal serialization. I believe these schema's come from geojson, but I could be wrong. In the end, I end up with the following compiler error:
Serializer has not been found for type 'java.math.BigDecimal'. To use context serializer as fallback, explicitly annotate type or property with @Contextual
To fix this error, I have to hand edit the file to add the annotation before it's allowed to compile.
It's possible this is actually an kotlinx serialization bug report, so please let me know if this is not within y'all's domain.
I would expect that the serialization library would just add the contextual annotation, thus saving me from hand editing generated files. One file seems okay to manipulate by hand, but I worry about maintenance.
openapi-generator version
7.11.0
OpenAPI declaration file content or url
Generation Details
Run during a gradle build process. Generator code below, version is 7.11.0, using kotlinx_serialization library
Steps to reproduce
Attempt to generate a kotlin data class from the above json schema using the following generator code
Generator code
tasks.register<org.openapitools.generator.gradle.plugin.tasks.GenerateTask>("generateTypes") {
generatorName.set("kotlin")
configOptions.set(
mapOf(
"serializationLibrary" to "kotlinx_serialization",
"useKotlinDataClasses" to "true",
"mapType" to "Map",
"generateSupportingFiles" to "false",
"generateTestFiles" to "false",
),
)
}
Suggest a fix
My guess is that this problem exists because of the handling of nullable properties.