Skip to content
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

Spring: support all media-types for consumes #58

Merged
merged 1 commit into from
Aug 19, 2021

Conversation

iazel
Copy link
Contributor

@iazel iazel commented Jun 11, 2021

Problem

In Spring, we require the usage of @RequestBody annotation before we actually check for consumes in @RequestMapping (or any variation of that). This is quite limiting because @RequestBody only supports application/json and application/xml media-type.
For example, it is currently impossible to use mutlipart/form-data media type.

Solution

Only check for @RequestBody in case there is no consumes annotation already provided in RequestMapping.

Potential improvements

We could make it a little more smart and set it to multipart/form-data in case we use @RequestPart or one of the parameter if of type MultipartFile. I honestly think this is more of an edge case and probably it's not worth it to add this extra complexity, but let me know what you think :)

@K0nstantine
Copy link

We also need this feature. Also the "@RequestPart" improvement.

@cc-jhr
Copy link
Collaborator

cc-jhr commented Aug 19, 2021

Hi @iazel,

thank you for providing this PR.
Looks good to me.

@cc-jhr cc-jhr merged commit 1ae5d0a into codecentric:master Aug 19, 2021
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.

3 participants