Skip to content

Fix default YAML media type mapping in Spring MVC - #37725

Open
TAKETODAY wants to merge 1 commit into
spring-projects:mainfrom
TAKETODAY:fix/default-yaml-media-type-mapping
Open

TAKETODAY wants to merge 1 commit into
spring-projects:mainfrom
TAKETODAY:fix/default-yaml-media-type-mapping

Conversation

@TAKETODAY

Copy link
Copy Markdown
Contributor

Summary

WebMvcConfigurationSupport#getDefaultMediaTypes() checks for application/atom+xml before registering the default yaml mapping. As a result, a YAML-only converter configuration misses the mapping, while an Atom-only configuration incorrectly registers it.

- if (supportedMediaTypes.contains(MediaType.APPLICATION_ATOM_XML)) {
+ if (supportedMediaTypes.contains(MediaType.APPLICATION_YAML)) {
      map.put("yaml", MediaType.APPLICATION_YAML);
  }

Evidence

Added two regression tests in WebMvcConfigurationSupportTests:

Configured converter supports Before After
Only YAML No yaml mapping Registers yaml as application/yaml
Only Atom Registers both atom and yaml Registers only atom

Both tests failed before the fix. After the fix, ./gradlew :spring-webmvc:check passed.

Merge Danger

Door: Two-way. The change is easy to revert.

Blast Radius: Spring MVC's default yaml media type mapping. The atom mapping and message converter configuration are unchanged.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 19, 2026
Register the default YAML mapping when a configured message converter
supports application/yaml, not application/atom+xml. Add regression
tests for YAML-only and Atom-only converter configurations.

Signed-off-by: 海子 Yang <i.take.today@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants