Skip to content

Fix unexpected merging of media types #3026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Mattias-Sehlstedt
Copy link

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, but due to the lack of descriptive testing together with values been 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
@@ -478,7 +497,7 @@ public void setWithResponseBodySchemaDoc(boolean withResponseBodySchemaDoc) {
public void calculateHeadersForClass(Class<?> declaringClass) {
RequestMapping reqMappingClass = AnnotatedElementUtils.findMergedAnnotation(declaringClass, RequestMapping.class);
if (reqMappingClass != null) {
fillMethods(reqMappingClass.produces(), reqMappingClass.consumes(), reqMappingClass.headers());
setHeaders(reqMappingClass.headers());
Copy link
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.

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
1 participant