-
Notifications
You must be signed in to change notification settings - Fork 472
When @EnableHypermediaSupport has no types, only enable user-defined media types. #1060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Clean up code containing various patterns: * Remove redundant `final`, `public`, and `static` declarations in interfaces and enums. * Replace redundant `? extends Object` generic parameters with `?`. * Convert collections to arrays using empty array instead of pre-sized one (modern JVM recommendation). * Initialize collections using constructor call over `addAll`. * Favor `addAll` over iterating and adding one-by-one. * Take advantage of `Map.forEach` that was introduced with Java 8.
When using an empty list, the old code had this: if (types.isEmpty()) {
return configurationProviders.toArray(new String[0]);
} This was incorrect, and would produce an Instead, the purpose is to enable ALL the if (types.isEmpty()) {
return configurationProviders.stream() //
.map(MediaTypeConfigurationProvider::getConfiguration) //
.map(Class::getName) //
.toArray(String[]::new);
} |
Since a return configurationProviders.stream() //
.filter(it -> {
// If there are no types, then let them all through
if (types.isEmpty()) {
return true;
}
// Filter the ones supporting the given media types
return it.supportsAny(types);
}) //
.map(MediaTypeConfigurationProvider::getConfiguration) //
.map(Class::getName) //
.toArray(String[]::new); |
Duplicates #1015 . |
Default it to being empty. Existing code, `@EnableHypermediaSupport(types = HAL)` will still operate as expected. But simply using the annotation with no arguments will activate ALL types.
Default it to being empty. Existing code, `@EnableHypermediaSupport(types = HAL)` will still operate as expected. But simply using the annotation with no arguments will activate ALL types.
Default it to being empty. Existing code, `@EnableHypermediaSupport(types = HAL)` will still operate as expected. But simply using the annotation with no arguments will activate ALL types. Related pull request: #1065.
UPDATE: If enabled but empty, then don't register the pre-built ones. BUT activate custom ones. Issue a warning if NO hypermedia types are found. |
As discussed in a video call, we are switching it up so that enabling hypermedia support with no specified types, Spring HATEOAS will attempt to ONLY enable user-defined types. If NO media types are found, issue a warning that you've enabled hypermedia support but not provided a media type. This will avoid enabling newly added types from the team. May want to include a custom annotation where the user can define a mediatype, but shield it from being picked up. |
Because Only alternative to ANY sort of check sounds like some lifecycle event handler that validates right before the app goes active. |
If an empty list of hypermedia types is provided, activate all of them.
Also consider making an empty list the default value for this annotation.
The text was updated successfully, but these errors were encountered: