Skip to content

Conversation

justinplus
Copy link

The discriminator property name should not be camel-cased, and the key-value pair of discriminator mappings map is reversed in latest code.

For example, this one-of definition would generate wrong java model interface as follows.

NewDeployment:
  oneOf:
    - $ref: '#/components/schemas/MappingDeployment'
  discriminator:
    propertyName: deployment_type
    mapping:
      mapping_deployment: '#/components/schemas/MappingDeployment'

Java model interface generated

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "deploymentType", visible = true )
@JsonSubTypes({
    @JsonSubTypes.Type(value = #/components/schemas/MappingDeployment.class, name = "mapping_deployment"),
    @JsonSubTypes.Type(value = mapping_deployment.class, name = "MappingDeployment"),
})
public interface NewDeployment {
}

After fix, it would be

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "deployment_type", visible = true )
@JsonSubTypes({
    @JsonSubTypes.Type(value = MappingDeployment.class, name = "mapping_deployment"),
})
public interface NewDeployment {
}

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

Successfully merging this pull request may close these issues.

1 participant