Produce IANA registered flavor of HAL media type by default.
Fixes GH-2454.
This commit is contained in:
committed by
Mark Paluch
parent
c0095a2a93
commit
ca5f6a73e7
@@ -21,13 +21,10 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.repository.support.Repositories;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
import org.springframework.data.rest.core.mapping.ExposureConfiguration;
|
||||
import org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy;
|
||||
import org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy.RepositoryDetectionStrategies;
|
||||
import org.springframework.data.rest.core.support.EntityLookup;
|
||||
import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.hateoas.server.LinkRelationProvider;
|
||||
import org.springframework.hateoas.server.core.AnnotationLinkRelationProvider;
|
||||
@@ -57,7 +54,7 @@ public class RepositoryRestConfiguration {
|
||||
private String pageParamName = "page";
|
||||
private String limitParamName = "size";
|
||||
private String sortParamName = "sort";
|
||||
private MediaType defaultMediaType = MediaTypes.HAL_JSON;
|
||||
private MediaType defaultMediaType = MediaTypes.VND_HAL_JSON;
|
||||
private boolean useHalAsDefaultJsonMediaType = true;
|
||||
private Boolean returnBodyOnCreate = null;
|
||||
private Boolean returnBodyOnUpdate = null;
|
||||
|
||||
@@ -80,7 +80,7 @@ class HalExplorerIntegrationTests {
|
||||
|
||||
mvc.perform(get(BASE_PATH).accept(MediaType.ALL)).//
|
||||
andExpect(status().isOk()).//
|
||||
andExpect(header().string(HttpHeaders.CONTENT_TYPE, startsWith(MediaTypes.HAL_JSON.toString())));
|
||||
andExpect(header().string(HttpHeaders.CONTENT_TYPE, startsWith(MediaTypes.VND_HAL_JSON.toString())));
|
||||
}
|
||||
|
||||
@Test // DATAREST-293
|
||||
|
||||
@@ -574,8 +574,8 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
|
||||
RepositoryRestConfiguration repositoryRestConfiguration) {
|
||||
|
||||
ArrayList<MediaType> mediaTypes = new ArrayList<>();
|
||||
mediaTypes.add(MediaTypes.HAL_JSON);
|
||||
mediaTypes.add(MediaTypes.VND_HAL_JSON);
|
||||
mediaTypes.add(MediaTypes.HAL_JSON);
|
||||
|
||||
// Enable returning HAL if application/json is asked if it's configured to be the default type
|
||||
if (repositoryRestConfiguration.useHalAsDefaultJsonMediaType()) {
|
||||
|
||||
Reference in New Issue
Block a user