OpenAPITools / OpenAPITools/openapi-generator
[REQ] Support Polymorphic Annotations for JSONB
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
According to the official communication of EF, JSONB now supports polymorphism: https://projects.eclipse.org/projects/ee4j.jsonb/releases/3.0.0
There is not much documentation about it, but I found the following example:
@JsonbTypeInfo({
@JsonbSubtype(alias = "dog", type = Dog.class)
@JsonbSubtype(alias = "cat", type = Cat.class)})
interface Animal {}
class Dog implements Animal {
public String isDog = true;
}
class Cat implements Animal {
public String isCat = true;
}
The behaviour seems quite similar to the existing @JsonTypeInfo Annotation of Jackson. We really need this feature in order to use polymorphic DTO's with JSONB. Alternatively we could use Jackson, but unfortunately the microprofile Generator does not support it (yet).
Describe the solution you'd like
As you already implemented a type info annotation for Jackson (see https://github.com/OpenAPITools/openapi-generator/blob/60dcf8613f6b75b606757c4a991fe018ad10ee99/modules/openapi-generator/src/main/resources/kotlin-spring/typeInfoAnnotation.mustache) it would be great to have the same for JSONB.
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 modules/openapi-generator/src/main/resources/kotlin-spring/typeInfoAnnotation.mustache, which the issue cites, and trace how that template is selected for generated Java outputs. Identify the JSONB target generators and expected annotation behavior from the example; done means generated polymorphic DTOs use JSONB type-info annotations and relevant generation tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100