GithubHelp home page GithubHelp logo

Comments (10)

dheerajuppalapati avatar dheerajuppalapati commented on August 24, 2024 2

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.

from springfox-demos.

NiteshMehta avatar NiteshMehta commented on August 24, 2024 2

Thanks Dilip
FileUploadController.java actually works, but its just that when we change @RequestPart String description to @RequestPart RequestObject requestObject it produces following error org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported

so does this means that it is partially supported?

from springfox-demos.

dilipkrish avatar dilipkrish commented on August 24, 2024

Swagger-ui does not support multipart file upload

from springfox-demos.

NiteshMehta avatar NiteshMehta commented on August 24, 2024

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 @RequestPart String description to @RequestPart RequestObject requestObject

I am getting error
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported

Even the curl generated by swagger-ui produces same error, but once I add type=application/json to body problem is fixed
curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' -F 'requestObject=@/req.json;type=application/json' 'http://localhost:8080/MyService/api/upload'

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
springboot Version 1.5.4.RELEASE

from springfox-demos.

dilipkrish avatar dilipkrish commented on August 24, 2024

Request parts, and multipart requests in general are not supported by swagger-ui. Atleast as of version 2.0 of the spec.

from springfox-demos.

NiteshMehta avatar NiteshMehta commented on August 24, 2024

Hi Dilip,
I am confused here, isn't FileUploadController.java multipart request with two request parts ?

from springfox-demos.

dilipkrish avatar dilipkrish commented on August 24, 2024

It is but swagger-ui and OpenAPI spec in general doesnt support multipart requests well. FileUploadController is just to demonstrate that springfox tries to generate the right description

from springfox-demos.

rajademo avatar rajademo commented on August 24, 2024

Dilip / Nitesh, any update on this issue.
I'm also facing the same issue. When i change @RequestPart String to @RequestPart Object, i'm getting the error.

from springfox-demos.

dilipkrish avatar dilipkrish commented on August 24, 2024

Multipart requests are not supported very well in Swagger-ui unfortunately

from springfox-demos.

ahmeterdem avatar ahmeterdem commented on August 24, 2024

"Multipart requests are not supported very well in Swagger-ui unfortunately"
then for file upload instead of multipart file which data type can we use?

from springfox-demos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.