From d8cf332c2e777e1d3009f53334350680c4f1a1b5 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 23 Mar 2022 12:09:48 +0000 Subject: [PATCH] Document default value of spring.thymeleaf.reactive.media-types Closes gh-30280 --- ...itional-spring-configuration-metadata.json | 19 +++++++++++++++++++ ...ymeleafReactiveAutoConfigurationTests.java | 15 ++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index c03d5d5dcb..88d480c284 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -1766,6 +1766,25 @@ "name": "spring.thymeleaf.prefix", "defaultValue": "classpath:/templates/" }, + { + "name": "spring.thymeleaf.reactive.media-types", + "defaultValue": [ + "text/html", + "application/xhtml+xml", + "application/xml", + "text/xml", + "application/rss+xml", + "application/atom+xml", + "application/javascript", + "application/ecmascript", + "text/javascript", + "text/ecmascript", + "application/json", + "text/css", + "text/plain", + "text/event-stream" + ] + }, { "name": "spring.thymeleaf.suffix", "defaultValue": ".html" diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java index f243e78d27..c4e2f8d2c3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java @@ -87,11 +87,24 @@ class ThymeleafReactiveAutoConfigurationTests { }); } + @Test + void defaultMediaTypes() { + this.contextRunner.run( + (context) -> assertThat(context.getBean(ThymeleafReactiveViewResolver.class).getSupportedMediaTypes()) + .containsExactly(MediaType.TEXT_HTML, MediaType.APPLICATION_XHTML_XML, + MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_RSS_XML, + MediaType.APPLICATION_ATOM_XML, new MediaType("application", "javascript"), + new MediaType("application", "ecmascript"), new MediaType("text", "javascript"), + new MediaType("text", "ecmascript"), MediaType.APPLICATION_JSON, + new MediaType("text", "css"), MediaType.TEXT_PLAIN, MediaType.TEXT_EVENT_STREAM) + .satisfies(System.out::println)); + } + @Test void overrideMediaTypes() { this.contextRunner.withPropertyValues("spring.thymeleaf.reactive.media-types:text/html,text/plain").run( (context) -> assertThat(context.getBean(ThymeleafReactiveViewResolver.class).getSupportedMediaTypes()) - .contains(MediaType.TEXT_HTML, MediaType.TEXT_PLAIN)); + .containsExactly(MediaType.TEXT_HTML, MediaType.TEXT_PLAIN)); } @Test