Skip to content

Conversation

@Mattias-Sehlstedt
Copy link
Contributor

@Mattias-Sehlstedt Mattias-Sehlstedt commented Jun 21, 2025

Fixes #3023

A minimal suggested fix. Given the description provided in the issue, I do not see how mergeArrays should ever be involved with any media type processing, since the media type documentation states that they should override rather than join the types. But due to the lack of descriptive testing together with values being set upon class instantiation and then later changed with a method invocation, I am hesitant to do too much of a change.

Feel free to use and contribute with the unit tests in this PR if you implement a change, since they add a lot of information with regard to what is an implicit/explicit behavior.

…y media type that is defined on the class level
RequestMapping reqMappingClass = AnnotatedElementUtils.findMergedAnnotation(declaringClass, RequestMapping.class);
if (reqMappingClass != null) {
fillMethods(reqMappingClass.produces(), reqMappingClass.consumes(), reqMappingClass.headers());
setHeaders(reqMappingClass.headers());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fillMethods triggered a media type recalculation that made the types become incorrectly assigned as the class media types. Given the name of the method, I removed the call to fillMethods and instead simply invoked setHeaders which is invoked lastly in the fillMethods method.

@bnasslahsen bnasslahsen merged commit 2af2bc5 into springdoc:main Jul 27, 2025
1 check passed
@bnasslahsen
Copy link
Collaborator

@Mattias-Sehlstedt,

Thank you so much for your contribution.

@Mattias-Sehlstedt Mattias-Sehlstedt deleted the method-media-type-override-class-media-type branch October 17, 2025 19:00
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.

Unexpected merging of media types

2 participants