TS interface and model generation for org.immutables generated objects

Hi,
I’m currently evaluating Hilla for internal projects that need fast pace backend/UI creation. Our current stack is mainly Java (Spring) backends with React frontends.

I’m facing an issue to use Hilla as our best practices require to use immutable objects, based on implem/builder generation from interfaces using org.immutables lib.

The issue comes from the OpenAPIObjectGenerator filtering endpoint parameters classes when being interfaces. This is linked to the way the schema generator is using the getDeclaredFields() of a class to retrieve the fields to generate a schema property for.

I was wandering if there would be a way to handle my use-case by letting the OpenAPIObjectGenerator know that my XXX interface has a @JsonDeserialize(as=XXXImpl.class) annotation so that the generator can extract the schema from the XXXImpl instead of the XXX interface ?

If you think about other workarounds, I would be happy to discuss !

Thx a lot for your help !

Hereby follows the few code samples that show up the case based on Grocery getting started :

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Value.Style(
        get = {"get*", "is*"},
        typeImmutable = "*Dto",
        jdkOnly = true,
        optionalAcceptNullable = true,
        privateNoargConstructor = true
)
public @interface Dto {
}
@Dto
@Value.Immutable
@JsonDeserialize(as = GroceryItemDto.class)
public interface GroceryItem {
    @NotBlank
    String getName();

    @NotNull
    @Min(value = 1)
    Integer getQuantity();
}
@Endpoint
@AnonymousAllowed
public class GroceryEndpoint {

    private final List<GroceryItem> groceryList = new ArrayList<>();

    public @Nonnull List<@Nonnull GroceryItem> getGroceries() {
        return groceryList;
    }

    public GroceryItem save(GroceryItem item) {
        groceryList.add(item);
        return item;
    }
}

generated ts model and interface:

export default interface GroceryItem {
}
export default class GroceryItemModel<T extends GroceryItem = GroceryItem> extends ObjectModel<T> { 
  declare static createEmptyValue: () => GroceryItem;
}

I’ve tried with preview feature com.vaadin.experimental.hillaEngine=true but it leads to an error while starting hilla-grocery-app:

stacktrace.txt (6.85 KB)