In order for jackson ObjectMapper to deserialize correctly a base class to its subclasses, we need to include annotations defining all expected subclasses in the parent class.
The codegen currently does not generate those annotations.
For this example YAML:
definitions:
Base:
type: object
discriminator: disc
properties:
disc:
type: string
required:
- disc
SubClass:
allOf:
- $ref: '#/definitions/Base'
required:
- field
properties:
field:
type: string
Jackson expects these annotations to be produced, but they are not:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "disc")
@JsonSubTypes({ @type(value = SubClass.class, name = "SubClass") })
public class Base {
}
In order for jackson ObjectMapper to deserialize correctly a base class to its subclasses, we need to include annotations defining all expected subclasses in the parent class.
The codegen currently does not generate those annotations.
For this example YAML:
definitions:
Base:
type: object
discriminator: disc
properties:
disc:
type: string
required:
- disc
SubClass:
allOf:
- $ref: '#/definitions/Base'
required:
- field
properties:
field:
type: string
Jackson expects these annotations to be produced, but they are not:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "disc")
@JsonSubTypes({ @type(value = SubClass.class, name = "SubClass") })
public class Base {
}