Endpoint Generator and Class Type Generation for Derived Classes

Dear all, I like to return from my endpoint a list of objects which have different types but all derived from a common abstract base class. But when I look at the generated TypeScript files then just generates my abstract base class but not the derived classes.

Does anybody know if this is a limitation of Hilla or if I need to configure something?

public abstract class AbstractContent {} 
public class BlogContent extends AbstractContent {}
public class FAQContent extends AbstractContent{}

// Endpoint 
public class ContentEndpoint  {
    public List<AbstractContent> getContent() {
           List<AbstractContent> list = new ArrayList<>();
           list.add(new BlogContent(...));
           list.add(new FAQContent(...));
       return list;

This only generates the “AbstractContent.ts” but no other derived classes like “BlogContent.ts” get created or used at Runtime.

Any hints how this scenario should be covered and used in Hilla?

Thank you

Sounds like you want this https://github.com/vaadin/hilla/issues/438

Thank you , yes this seems to be the direction. Do you know if it is already supported by Hilla ? I added the @JsonTypeInfo and @JsonSubTypes notation to my abstract class but it seems to make no difference. Means the derived classes get not generated.

Looking at the Pull request, it’s should be supported in 2.3

I don’t know the details, looking at the example from the PR description, that’s how it should work tho https://github.com/vaadin/hilla/pull/1336

Not sure if it happens because of your class is abstract and it has to be non-abstract

Yes you are right. The classes got generated with Hilla 2.3. But the serialization and deserialization is in my example not yet working

Ok it seems not yet to be fully supported. The xxxxUnion class get generated but not yet used for the method or return type when the endpoint classes get generated. See https://github.com/vaadin/hilla/issues/1457