Swagger upload file
See original GitHub issueI’m submitting a…
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
After update to 4.x version, stops working uploading files in swagger ui
Expected behavior
File uploaded
Minimal reproduction of the problem with instructions
https://github.com/gulaandrij/nest-monorepo-swagger
- yarn
- nest start
- go to
http://localhost:3000/api
- try to upload
What is the motivation / use case for changing the behavior?
Environment
Nest version: 6.7.2
For Tooling issues:
OS Version : Linux 5.3
NodeJS Version : v13.1.0
YARN Version : 1.19.2
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
File Upload - Swagger
File Upload. In OpenAPI 3.0, you can describe files uploaded directly with the request content and files uploaded with multipart requests. Use the...
Read more >How to post files in Swagger (OpenAPI)? - Stack Overflow
and now I see the file upload option on my Swagger UI page. But when I select a file and click "try it...
Read more >File Upload via Swagger - codeburst
The code snippet below shows an example action method which allows two files be uploaded at the same time. The Swagger UI then...
Read more >Testing file upload with Swagger in ASP.Net core - Medium
Testing file upload with Swagger in ASP.Net core. preview image. Let's assume you have an API which is used for uploading image to...
Read more >Upload File to Swagger UI OpenAPI Specification - YouTube
Add file uploading in Swagger UI using OpenAPI Specification V3.0 using IFormFile inbuilt support for Upload.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please double check the latest documentations on File Upload
Here’s a quick fix:
You can always create a custom decorator like this:
then use it:
If your
FileInterceptor()
has a differentfieldName
likeFileInterceptor('avatar')
then adjust like so:Make sure to adjust your
UploadedFile
if you submit aFormData
with many different values + file.I figured this one out after a long time:
since you already have
@ApiConsumes("multipart/form-data")
Swagger generated code is ok. But Swagger UI will not work since multiple file upload is not supported yet.
So, in a fact you don’t really need seperate decorator you can just use
and then in your TS client you will just have
new FormData()
and then append files.Both of these decorators generate Typescript code with
function(model: Blob)
.What a waste of time!!!
By far these @nestjs guys are so slow on to respond. They could saved me 5 days!