Add web support for Yaml via Jackson

This commit adds support for application/yaml in MediaType and leverages
jackson-dataformat-yaml in order to support Yaml in RestTemplate,
RestClient and Spring MVC.

See gh-32345
This commit is contained in:
Hyoungjune
2024-02-29 16:26:26 +09:00
committed by Sébastien Deleuze
parent 246e4977a2
commit 6a8f0d6d7d
11 changed files with 177 additions and 2 deletions

View File

@@ -79,6 +79,7 @@ import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
import com.fasterxml.jackson.dataformat.xml.XmlFactory;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import kotlin.ranges.IntRange;
import org.junit.jupiter.api.Test;
@@ -95,6 +96,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Sebastien Deleuze
* @author Eddú Meléndez
* @author Hyoungjune Kim
*/
@SuppressWarnings("deprecation")
class Jackson2ObjectMapperBuilderTests {
@@ -588,6 +590,13 @@ class Jackson2ObjectMapperBuilderTests {
assertThat(objectMapper.getFactory().getClass()).isEqualTo(SmileFactory.class);
}
@Test
void yaml() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.yaml().build();
assertThat(objectMapper).isNotNull();
assertThat(objectMapper.getFactory().getClass()).isEqualTo(YAMLFactory.class);
}
@Test
void visibility() throws JsonProcessingException {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()