Bug Report Checklist
Description
When the property used as discriminator is specified as a property within the model definitions and jackson is used as serialization library, the discriminator is serialized twice.
openapi-generator version
7.14.0
OpenAPI declaration file content or url
components:
schemas:
ShapeType:
type: string
enum:
- TRIANGLE
- SQUARE
Shape:
type: object
required:
- type
properties:
type:
$ref: "#/components/schemas/ShapeType"
discriminator:
propertyName: type
mapping:
TRIANGLE: '#/components/schemas/Triangle'
SQUARE: '#/components/schemas/Square'
Triangle:
allOf:
- $ref: '#/components/schemas/Shape'
- type: object
required:
- base
- height
properties:
base:
type: number
height:
type: number
Square:
allOf:
- $ref: '#/components/schemas/Shape'
- type: object
required:
- side
properties:
side:
type: number
produces
[
{
"type": "TRIANGLE",
"base": 1,
"height": 1,
"type": "TRIANGLE"
},
{
"type": "SQUARE",
"side": 1,
"type": "SQUARE"
}
]
Generation Details
Using gradle plugin
configOptions.set(
mapOf(
"dateLibrary" to "java8",
"disallowAdditionalPropertiesIfNotPresent" to "false",
"documentationProvider" to "none",
"enumPropertyNaming" to "original",
"exceptionHandler" to "false",
"hideGenerationTimestamp" to "true",
"interfaceOnly" to "true",
"modelMutable" to "true",
"serializationLibrary" to "jackson",
"useSpringBoot3" to "true",
"useTags" to "true",
)
)
Steps to reproduce
- Generate using jackson as serialization library
- Check the JSON payload.
Related issues/PRs
Issue #9441 / PR #11691
Issue #3796
Suggest a fix
Adopt existing solution from Java / JavaSpring
Bug Report Checklist
Description
When the property used as discriminator is specified as a property within the model definitions and jackson is used as serialization library, the discriminator is serialized twice.
openapi-generator version
7.14.0
OpenAPI declaration file content or url
produces
[ { "type": "TRIANGLE", "base": 1, "height": 1, "type": "TRIANGLE" }, { "type": "SQUARE", "side": 1, "type": "SQUARE" } ]Generation Details
Using gradle plugin
configOptions.set( mapOf( "dateLibrary" to "java8", "disallowAdditionalPropertiesIfNotPresent" to "false", "documentationProvider" to "none", "enumPropertyNaming" to "original", "exceptionHandler" to "false", "hideGenerationTimestamp" to "true", "interfaceOnly" to "true", "modelMutable" to "true", "serializationLibrary" to "jackson", "useSpringBoot3" to "true", "useTags" to "true", ) )Steps to reproduce
Related issues/PRs
Issue #9441 / PR #11691
Issue #3796
Suggest a fix
Adopt existing solution from Java / JavaSpring