List of usage examples for org.springframework.data.rest.webmvc RestMediaTypes SCHEMA_JSON
MediaType SCHEMA_JSON
To view the source code for org.springframework.data.rest.webmvc RestMediaTypes SCHEMA_JSON.
Click Source Link
From source file:org.springframework.data.rest.webmvc.config.RepositoryRestMvConfigurationIntegrationTests.java
/** * @see DATAREST-424// www .j a v a 2s . c o m */ @Test public void halHttpMethodConverterIsRegisteredBeforeTheGeneralOne() { CollectingComponent component = context.getBean(CollectingComponent.class); List<HttpMessageConverter<?>> converters = component.converters; assertThat(converters.get(0).getSupportedMediaTypes(), hasItem(MediaTypes.HAL_JSON)); assertThat(converters.get(1).getSupportedMediaTypes(), hasItem(RestMediaTypes.SCHEMA_JSON)); }
From source file:org.springframework.data.rest.webmvc.config.RepositoryRestMvConfigurationIntegrationTests.java
/** * @see DATAREST-424//from w w w . j a va 2s . co m */ @Test public void halHttpMethodConverterIsRegisteredAfterTheGeneralOneIfHalIsDisabledAsDefaultMediaType() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( NonHalConfiguration.class); CollectingComponent component = context.getBean(CollectingComponent.class); context.close(); List<HttpMessageConverter<?>> converters = component.converters; assertThat(converters.get(0).getSupportedMediaTypes(), hasItem(RestMediaTypes.SCHEMA_JSON)); assertThat(converters.get(1).getSupportedMediaTypes(), hasItem(MediaTypes.HAL_JSON)); }
From source file:org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.java
/** * The {@link HttpMessageConverter} used by Spring MVC to read and write JSON data. * /*from w ww. j a v a2s. c o m*/ * @return */ @Bean public TypeConstrainedMappingJackson2HttpMessageConverter jacksonHttpMessageConverter() { List<MediaType> mediaTypes = new ArrayList<MediaType>(); // Configure this mapper to be used if HAL is not the default media type if (!config().useHalAsDefaultJsonMediaType()) { mediaTypes.add(MediaType.APPLICATION_JSON); } int order = config().useHalAsDefaultJsonMediaType() ? Ordered.LOWEST_PRECEDENCE - 1 : Ordered.LOWEST_PRECEDENCE - 10; mediaTypes.addAll(Arrays.asList(RestMediaTypes.SCHEMA_JSON, // RestMediaTypes.JSON_PATCH_JSON, RestMediaTypes.MERGE_PATCH_JSON, // RestMediaTypes.SPRING_DATA_VERBOSE_JSON, RestMediaTypes.SPRING_DATA_COMPACT_JSON)); TypeConstrainedMappingJackson2HttpMessageConverter jacksonConverter = new ResourceSupportHttpMessageConverter( order); jacksonConverter.setObjectMapper(objectMapper()); jacksonConverter.setSupportedMediaTypes(mediaTypes); return jacksonConverter; }