We have a set of Enums implementing a common interface. But in the generated code, the Enums are not implementing the interface. Using discriminatorMapping - the type is referenced as an External Property
Sample code - The issue, in this case is Cow and Sheep classes in the client do not implement Animal
@Schema(
description = "Animals",
discriminatorProperty = "type",
discriminatorMapping = [
DiscriminatorMapping(value = "COW_FARM", schema = Cow::class),
DiscriminatorMapping(value = "SHEEP_FARM", schema = Sheep::class),
],
)
@JsonTypeInfo(
use = JsonTypeInfo.Id.NONE,
include = JsonTypeInfo.As.EXTERNAL_PROPERTY,
property = "type",
)
@JsonSubTypes(
JsonSubTypes.Type(name = "COW_FARM", value = Cow::class),
JsonSubTypes.Type(name = "SHEEP_FARM", value = Sheep::class),
)
interface Animal
enum class Cow : Animal {
"Moo";
}
enum class Sheep : Animal {
"Baa";
}
enum class FarmType {
"COW_FARM",
"SHEEP_FARM";
}
interface Farm {
val type: FarmType
val animal: Animal
}
class CowFarm : Farm {
val type : FarmType = FarmType.COW_FARM,
val animal: Cow
}
class SheepFarm : Farm {
val type : FarmType = FarmType.SHEEP_FARM,
val animal: Sheep
}
We have a set of Enums implementing a common interface. But in the generated code, the Enums are not implementing the interface. Using discriminatorMapping - the type is referenced as an External Property
Sample code - The issue, in this case is Cow and Sheep classes in the client do not implement Animal