-
Notifications
You must be signed in to change notification settings - Fork 351
FileUpload not working with JSON data #40
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
Comments
Swagger-ui does not support multipart file upload |
I'm guessing this is not the right place to ask questions about springfox?? Every-time I ask questions I get answers from you which do not make sense. What does this mean "Swagger-ui does not support multipart file upload"?? Springfox is build on swagger and example you posted for sprinfox here https://github.com/springfox/springfox-demos/blob/be4118bb031c8dcded514c33d74cae52fc51ff08/boot-swagger/src/main/java/springfoxdemo/boot/swagger/web/FileUploadController.java is for Multipart file upload. I asked a simple question and I keep getting ridiculous answer. |
I am also facing similar problem with https://github.com/springfox/springfox-demos/blob/be4118bb031c8dcded514c33d74cae52fc51ff08/boot-swagger/src/main/java/springfoxdemo/boot/swagger/web/FileUploadController.java When I modify I am getting error Even the curl generated by swagger-ui produces same error, but once I add type=application/json to body problem is fixed looking at swagger-api/swagger-core#636, it looks like swagger-ui have support to provide content-type for RequestPart. springfox version 2.7.0 |
Request parts, and multipart requests in general are not supported by swagger-ui. Atleast as of version 2.0 of the spec. |
Hi Dilip, |
It is but swagger-ui and OpenAPI spec in general doesnt support multipart requests well. |
Thanks Dilip so does this means that it is partially supported? |
Dilip / Nitesh, any update on this issue. |
Multipart requests are not supported very well in Swagger-ui unfortunately |
"Multipart requests are not supported very well in Swagger-ui unfortunately" |
I tried the example https://github.com/springfox/springfox-demos/blob/be4118bb031c8dcded514c33d74cae52fc51ff08/boot-swagger/src/main/java/springfoxdemo/boot/swagger/web/FileUploadController.java
Just changed the @RequestPart String description to @RequestBody Component component which should be a JSON input.
Here is the code sample
@RequestMapping(value = "/v1/component/fileupload", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public Component fileComplaint(
@RequestBody Component component, @RequestPart MultipartFile file){
...........................
}
Here is what the swagger-ui looks like

Here is the request details


Here is the response details

Here are my questions:
I'm not sure why does say
in swagger-ui. It should say "application/json" instead. How do i fix this?
If you request at the request paramaters, the data i'm putting in the "component" parameter is not being sent to the back-end. It only sends the file details.
How do i fix org.springframework.web.HttpMediaTypeNotSupportedException??
Any kind of help will be appreciated. I already checked out the suggestions in springfox/springfox#134 and it was of no help
Thanks,
Dheeraj
The text was updated successfully, but these errors were encountered: