Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum subtypes don't properly inherit from a defined parent type #293

Open
bapatd opened this issue Jun 21, 2024 · 1 comment
Open

enum subtypes don't properly inherit from a defined parent type #293

bapatd opened this issue Jun 21, 2024 · 1 comment

Comments

@bapatd
Copy link

bapatd commented Jun 21, 2024

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
}
@cjbooms
Copy link
Owner

cjbooms commented Aug 22, 2024

Please provide an example OpenApi3 schema, with expected output vs actual output so we can diagnose and attempt a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants