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

Fix discriminator property name and mapping $ref value #1287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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