I try to use Java records as input parameter types for request bodies because I'd like to treat the data as immutable. However, Spring Hateoas does not fully support HAL Forms metadata for this approach.
I can add many of the annotations described at https://docs.spring.io/spring-hateoas/docs/current/reference/html/#mediatypes.hal-forms.metadata to record constructor parameters, but not InputType. I get a compile error '@InputType' not applicable to parameter because of its @Target definition.
I can apply Hibernate's @Length annotation to a record constructor param, but Spring Hateoas does not evaluate it, the HAL Form property is rendered without the length information.
Also, record constructor arguments are rendered as readOnly, although a caller can send them to change those arguments. Maybe an additional @ReadOnly annotation would be in order to tell consumers whether or not a data item may be used to alter the value of this element, if no setter is present.
Bottom line: could we support HAL Forms metadata Java records just like classes?
I try to use Java records as input parameter types for request bodies because I'd like to treat the data as immutable. However, Spring Hateoas does not fully support HAL Forms metadata for this approach.
I can add many of the annotations described at https://docs.spring.io/spring-hateoas/docs/current/reference/html/#mediatypes.hal-forms.metadata to record constructor parameters, but not
InputType. I get a compile error'@InputType' not applicable to parameterbecause of its@Targetdefinition.I can apply Hibernate's
@Lengthannotation to a record constructor param, but Spring Hateoas does not evaluate it, the HAL Form property is rendered without the length information.Also, record constructor arguments are rendered as
readOnly, although a caller can send them to change those arguments. Maybe an additional@ReadOnlyannotation would be in order to tell consumers whether or not a data item may be used to alter the value of this element, if no setter is present.Bottom line: could we support HAL Forms metadata Java records just like classes?