Handling common record properties in Java interfaces
lpandzic opened this issue · comments
Lovro Pandžić commented
Is there a way, similar to java bean classes and interfaces, to have typescript generator generate properties for interfaces over java records?
Java Bean example:
public class A implements I {
private final String b;
... constructor and getter
}
public interface I {
String getB();
}
Generated typescript:
interface I {
b: string
}
However, if I apply similar pattern to java records it doesn't work:
public record A (String b) implements I {
}
public interface I {
String b();
}
Generated typescript:
interface I {
}
Is this use case supported by some mechanism?
Lovro Pandžić commented
After remembering that typescript generator uses jackson under the hood to detect properties the solution was evident:
public record A (String b) implements I {
}
public interface I {
@JsonGetter
String b();
}
Generated typescript:
interface I {
b: string
}