OpenAPITools / OpenAPITools/openapi-generator
[BUG][KOTLIN] Override is missing when parent entity has enum
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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,
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing generation with the supplied OAS 3.0 schema and compare the generated Kotlin ChildA model with the expected output. Verify that the shared enum property is marked override and receives the ChildA default value, while preserving the behavior of the other inherited properties.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100