Skip to content

[Spring] duplicated disciminator field in REST response when existing property is used for polimorphism #459

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

Open
rrobsonm opened this issue Sep 5, 2019 · 1 comment

Comments

@rrobsonm
Copy link

rrobsonm commented Sep 5, 2019

I am using swagger-codegen-maven-plugin version: 2.4.8
If discriminator and property exists with the same name. Spring rest response has duplicated fields.

for such definition:
"Pet": { "type": "object", "required": [ "name", "petType" ], "properties": { "name": { "type": "string" }, "petType": { "type": "string" } }, "discriminator": "petType", }

it is generated:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type", visible = true )

JsonTypeInfo.As.PROPERTY is always generated(it is not parametrized anyway) It would be better to generate in such case:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "@type", visible = true )

So fields won't be duplicated in rest response.

@Zemke
Copy link

Zemke commented Jan 5, 2021

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

No branches or pull requests

2 participants