vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
904 stars 57 forks source link

Nullability of properties of types that use @JsonValue/@JsonCreator is ignored #2500

Open peholmst opened 4 months ago

peholmst commented 4 months ago

Describe the bug

Given the following Java classes:

public record TeamName(@JsonValue String value) {

    @JsonCreator
    public TeamName(String value) {
        this.value = validate(value);
    }

    public static String validate(String value) {
        // TODO implement validation
        return value;
    }
}

public record TeamReference(
        @Nonnull TeamName name
) {
}

The following TypeScript is generated:

interface TeamReference {
    name?: string;
}

Expected-behavior

The following TypeScript should be generated (name attribute should not be optional/nullable):

interface TeamReference {
    name: string;
}

Reproduction

Create the classes described above in a project and generate the corresponding TypeScript types.

System Info

MacOS 14.5, Chrome 125.0.6422.114, Vaadin 24.5.0.alpha1.