spring-hateoas
spring-hateoas copied to clipboard
`HalFormsConfiguration#withOptions` is based on a property name depending on an non obvious internal algorithm
I'd like to customize HalFormsConfiguration in order to be able to produce HAL-Forms options for some template payload properties via a home made annotation based engine.
My goal is to have something like this:
record Payload(@HalFormsPropertyMetadata(optionsFactory = MyOptionsFactory.class) String foo) {
}
class MyOptionsFactory implements OptionsFactory {
@Override
Optional<HalFormsOptions> createOptions(AffordanceModel.PropertyMetadata property) {
return Optional.empty();
}
}
public interface OptionsFactory {
Optional<HalFormsOptions> createOptions(AffordanceModel.PropertyMetadata property);
}
To do that, I need to invoke https://github.com/spring-projects/spring-hateoas/blob/688484610cb9ecf6ee24abae611997fc3b51f0c2/src/main/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsConfiguration.java#L170-L171
The property argument should be the name of the property for which we try to provide options. But this value is computed like this: https://github.com/spring-projects/spring-hateoas/blob/a796509532bf0bb4294eae0573a9839943c36403/src/main/java/org/springframework/hateoas/mediatype/PropertyUtils.java#L445-L456
Since this computation is private, I have no other way than copying the Spring HATEOAS name computation code in my project to make sure to match my annotated property with the name expected by Spring HATEOAS.
Nothing in the current HalFormsConfiguration is designed for extension, as it's impossible to do that without knowing what folks might envision to customize. Can you elaborate on what you're actually trying to achieve?