Skip to content

Commit 3b31829

Browse files
committed
Produce IANA registered flavor of HAL media type by default.
Fixes GH-2454.
1 parent d4ef250 commit 3b31829

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/RepositoryRestConfiguration.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@
2121
import java.util.List;
2222

2323
import org.springframework.data.repository.support.Repositories;
24-
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
25-
import org.springframework.data.rest.core.annotation.RestResource;
2624
import org.springframework.data.rest.core.mapping.ExposureConfiguration;
2725
import org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy;
2826
import org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy.RepositoryDetectionStrategies;
2927
import org.springframework.data.rest.core.support.EntityLookup;
30-
import org.springframework.hateoas.LinkRelation;
3128
import org.springframework.hateoas.MediaTypes;
3229
import org.springframework.hateoas.server.LinkRelationProvider;
3330
import org.springframework.hateoas.server.core.AnnotationLinkRelationProvider;
@@ -57,7 +54,7 @@ public class RepositoryRestConfiguration {
5754
private String pageParamName = "page";
5855
private String limitParamName = "size";
5956
private String sortParamName = "sort";
60-
private MediaType defaultMediaType = MediaTypes.HAL_JSON;
57+
private MediaType defaultMediaType = MediaTypes.VND_HAL_JSON;
6158
private boolean useHalAsDefaultJsonMediaType = true;
6259
private Boolean returnBodyOnCreate = null;
6360
private Boolean returnBodyOnUpdate = null;

spring-data-rest-hal-explorer/src/test/java/org/springframework/data/rest/webmvc/halexplorer/HalExplorerIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void exposesJsonUnderApiRootByDefault() throws Exception {
8080

8181
mvc.perform(get(BASE_PATH).accept(MediaType.ALL)).//
8282
andExpect(status().isOk()).//
83-
andExpect(header().string(HttpHeaders.CONTENT_TYPE, startsWith(MediaTypes.HAL_JSON.toString())));
83+
andExpect(header().string(HttpHeaders.CONTENT_TYPE, startsWith(MediaTypes.VND_HAL_JSON.toString())));
8484
}
8585

8686
@Test // DATAREST-293

spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,8 @@ public TypeConstrainedMappingJackson2HttpMessageConverter halJacksonHttpMessageC
574574
RepositoryRestConfiguration repositoryRestConfiguration) {
575575

576576
ArrayList<MediaType> mediaTypes = new ArrayList<>();
577-
mediaTypes.add(MediaTypes.HAL_JSON);
578577
mediaTypes.add(MediaTypes.VND_HAL_JSON);
578+
mediaTypes.add(MediaTypes.HAL_JSON);
579579

580580
// Enable returning HAL if application/json is asked if it's configured to be the default type
581581
if (repositoryRestConfiguration.useHalAsDefaultJsonMediaType()) {

0 commit comments

Comments
 (0)