Skip to content

Document media type API versions when produces is inherited or omitted - #3465

Open
6londe wants to merge 2 commits into
springdoc:mainfrom
6londe:fix/implicit-produces-api-version
Open

6londe wants to merge 2 commits into
springdoc:mainfrom
6londe:fix/implicit-produces-api-version

Conversation

@6londe

@6londe 6londe commented Dec 4, 2026

Copy link
Copy Markdown

Summary

With media-type API versioning, Spring can select different handlers for the same route when produces is inherited from the controller or omitted. The generated response under /v3/api-docs currently combines the schemas under an unversioned content key, even though requests with different version parameters select different handlers.

Apply the version parameter to compatible inherited or default response media types. Preserve existing media-type parameters and the method-level produces behavior. Leave incompatible and negated expressions intact.

Verification

  • On current main with the regression tests applied, the two OpenAPI assertions failed and the other 16 tests passed. After the fix, all 18 passed.
  • Ran ./mvnw -s <settings> -B -ntp -pl springdoc-openapi-starter-webmvc-api -am test -Dtest=ImplicitProducesApiVersionTest,SpringDocApp248Test,MethodAttributesTest -Dsurefire.failIfNoSpecifiedTests=false.
  • Ran ./mvnw -s <settings> -B -ntp -pl springdoc-openapi-starter-webmvc-api,springdoc-openapi-starter-webflux-api -am test. All 907 tests passed.
  • MockMvc verifies that requests for versions 1.0 and 2.0 reach the intended handlers and that their response schemas appear under separate keys in the generated document.

Local verification used JDK 21 and Maven settings that mirror the configured Spring repositories to Maven Central. Swagger UI rendering was outside the verification scope.

AI disclosure: Codex prepared and validated the change under the contributor's standing authorization.

* @author 6londe
*/
@ContextConfiguration(classes = ImplicitProducesApiVersionTest.TestApplication.class)
class ImplicitProducesApiVersionTest extends AbstractCommonTest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it looks like the placement of this test does not align with any pattern used in any other test suite in this repo? Is this intentional?

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants