OpenAPI 3.0.1 upload/download file example
See original GitHub issueDo you have an example of what an ASP.Net Core 3.0 API operation that uploads and downloads a file and what the OpenAPI 3.0.1 yaml should look like in order to properly generate a client using NSwag code generator?
I’ve tried every combination I can think of, and nothing seems to work. Either I get errors trying to deserialize to a FileContent
type, or I get errors about not finding the Content boundary
or else the client has random parameters that aren’t used or a myriad of other issues.
At this point, my yaml is identical to what’s on the OpenApi documentation page, but this doesn’t work, either: https://swagger.io/docs/specification/describing-request-body/file-upload/
I just need a working example to go off of so I can stop guessing.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:25 (2 by maintainers)
Top Results From Across the Web
File Upload
In OpenAPI 3.0, you can describe files uploaded directly with the request content and files uploaded with multipart requests. Use the requestBody keyword...
Read more >OpenAPI 3.0 - how to define file download operation correctly
I use online Swagger Editor with OpenAPI 3.0 and I have to create a definition file download. I develop server-side and a customer...
Read more >A Sample OpenAPI 3.0 File to Get Started
Familiarize yourself with the new OpenAPI specification version 3.0 by looking over this example file, with an analysis and thoughts from ...
Read more >OpenAPI 3.0 Tutorial | SwaggerHub Documentation
In this tutorial, we will write a simple API definition in the OpenAPI 3.0 format. If you are using OpenAPI 2.0 (Swagger 2.0),...
Read more >Post File in Swagger OpenAPI V3.0 and V2.0 examples
Post File in Swagger OpenAPI V3.0 and V2.0. Upload single or multiple files in Swagger UI using OpenAPI 3.0 or V2.0 specifications with...
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 Free
Top 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
Are you suggesting this to me? If so, thanks for the reply! But I know that the client needs to have
FormData
. But I don’t want to do that manually every time after I generate the client. The trick is to getnswag
to do that. But the solution that I used for dotnet core 2.x and 4.x swashbuckle, doesn’t work for dotnet core 3.x and swashbuckle 5.x.Hello, I had exactly the same issue, so I did like @mahinthan suggested, but it was not enough, in the request I got payload instead of formData, so the missing part of the solution is to delete the content type which have this value “multipart/form-data” from the generated code and it worked well
"Content-Type": "multipart/form-data"
But it’s not really practice to change manually a generated code, that’s why I added some code to the useTransformOptionsMethod remove the content type when it is equal to “multipart/form-data” Hope that it helps, and that will be fixed soon.