swagger-api / swagger-api/swagger-codegen
Discriminator - Java/Jackson - visible = true
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When I define a super type I specify a discriminator, so Jackson can deserialize the correct type. But I also have to define a property in that type, that has the same, because the the JsonTypeInfo is set as visible = true.
Is there a way to tell the generator to make it not visible? If that's not possible, I think it would be nice to have such an option, because the discriminator in (at least in my case) is not necessary in the deserialized object.
Swagger-codegen version
3.0.8
Swagger declaration file content or url
SuperType:
discriminator:
propertyName: objectType
properties:
# The generator sets the visibility of the discriminator to true, so I had to add it as property, otherwise it will not deserialize
objectType:
type: string
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "objectType", visible = true )
Command line used for generation
I'm using gradle plugin id 'org.hidetake.swagger.generator' version '2.18.1'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Swagger declaration's discriminator and the Java generator output containing @JsonTypeInfo. Trace how the generator handles the discriminator and its visible setting, then determine where an option could control that value. Done means generated Java models can omit discriminator visibility when requested without requiring a duplicate objectType property.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100