Skip to content

Discriminator mappings missing breaking generated object inheritance #164

@joeswiggin

Description

@joeswiggin

I have a set of objects that have a shared interface of type "Action." The yaml being produced includes a discriminator property name like it should, but it's missing the mapping. Here's what it looks like (kotlin, sorry):

@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.EXISTING_PROPERTY,
    property = "name",
    visible = true
)
@JsonSubTypes(
    value = [
        Type(name = "type1", value = ActionType1::class),
        Type(name = "type2, value = ActionType2::class),
        ...
    ]
)
interface Action {
  val name: String //this is the discriminator
  ...
}

This produces the following yaml:

    ActionObject:
      type: object
      properties:
        name:
          type: string
        ...
      discriminator:
        propertyName: name

It should also produce a mapping like so:

      discriminator:
        propertyName: name
        mapping:
          type1: '#/components/schemas/ActionType1'
          type2: '#/components/schemas/ActionType2'

Then a code generator will include the mappings on the resulting JsonSubTypes annotation as in the original source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions