openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[REQ] Support Polymorphic Annotations for JSONB

Open jishei-128 opened this issue 4 years ago • 0 comments

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.

jishei-128 avatar May 11 '22 14:05 jishei-128