You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Its possible this is actually an openapi bug report, so please let me know if this is not within y'all's domain.
tasks.register<org.openapitools.generator.gradle.plugin.tasks.GenerateTask>("generateTypes") {
dependsOn("copySchema")
if (!openApiSpec.exists()) {
error("OpenAPI spec not found at: ${openApiSpec.path}")
}
println("${layout.buildDirectory}")
inputSpec.set(openApiSpec.absolutePath)
outputDir.set(outputDirectory.absolutePath)
generatorName.set("kotlin")
configOptions.set(
mapOf(
"serializationLibrary" to "kotlinx_serialization",
"useKotlinDataClasses" to "true",
"mapType" to "Map",
"generateSupportingFiles" to "false",
"generateTestFiles" to "false",
),
)
}
Expected behavior
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.
Environment
IntelliJ IDE (And its associated kotlin version) : 2024.3.4.1
Library version: Unsure, openapi version 7.11.0
Kotlin platforms: JVM
Gradle version: 8.10
The text was updated successfully, but these errors were encountered:
Describe the bug
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 aPoint
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:To fix this error, I have to hand edit the file to add the annotation before it's allowed to compile.
Its possible this is actually an openapi bug report, so please let me know if this is not within y'all's domain.
To Reproduce
Json file to produce data class from
Generator code
Expected behavior
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.
Environment
The text was updated successfully, but these errors were encountered: