-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Labels
Description
Description
Kotlin generator generates incorrect
openapi-generator version
7.18.0
OpenAPI declaration file content or url
Shortened schemas
{
"InheritedOption" : {
"required" : [ "types" ],
"type" : "object",
"allOf" : [ {
"$ref" : "#/components/schemas/BaseOption"
} ]
},
"BaseOption" : {
"required" : [ "types"],
"type" : "object",
"properties" : {
"types" : {
"uniqueItems" : true,
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/SomeObject"
}
},
}
}Generation Details
InheritedOption does not actually override the base type, as it doesn't share the same collection type. It should generate Set in the parent as well. Now it causes compilation failure.
data class InheritedOption(
@get:JsonProperty("types")
override val types: kotlin.collections.Set<BaseOption>,
}
@JsonIgnoreProperties(
value = ["type"], // ignore manually set type, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the type to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true)
@JsonSubTypes(
JsonSubTypes.Type(value = InheritedOption::class, name = "InheritedOption"),
)
interface BaseOption {
@get:JsonProperty("types")
val types: kotlin.collections.List<BaseType>
}