openapi-generator
openapi-generator copied to clipboard
[BUG][KOTLIN] Override is missing when parent entity has enum
Description
When generating polymorphic entities using OAS 3.0, child entities do not add the override keyword to the enum that is present in both, parent and child entities.
openapi-generator version
6.3.0
Generation Details
Consider having a structure like this:
{
"openapi": "3.0.1",
"components": {
"schemas": {
"ChildA": {
"required": [
"enum"
],
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/Parent"
},
{
"type": "object",
"properties": {
"enum": {
"$ref": "#/components/schemas/Enum",
"default": "ChildA"
}
}
}
]
},
"Parent": {
"required": [
"enum"
],
"type": "object",
"properties": {
"enum": {
"$ref": "#/components/schemas/Enum"
},
"discriminator": {
"propertyName": "enum",
"mapping": {
"ChildA": "#/components/schemas/ChildA",
"ChildB": "#/components/schemas/ChildB"
}
}
},
"Enum": {
"enum": [
"ChildA",
"ChildB"
],
"type": "string"
}
}
}
}
}
After generation we got these models:
data class ChildA (
@Json(name = "enum")
val enum: Enum? = null,
@Json(name = "parentProperty")
override val parentProperty: ParentProperty? = null
) : Parent
The enum field must have override keyword, like other parent properties have. And enum property must have default value set like this:
override val enum: Enum? = Enum.ChildA,
Is there any upgrades?