OpenAPI v3 multipart/form-data
See original GitHub issueGiven the following OpenAPI v3 path:
/multipart_file_upload:
post:
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
responses:
200:
description: File uploaded
It would be expected that the generated C# client would allow specifying a filename and data source for the file upload, with MultipartFormDataContent being used under the hood. However, the only parameter that is generated is System.IO.Stream body
, which does not perform any sort of multipart encoding.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:14
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Multipart Requests
OAS 3 This guide is for OpenAPI 3.0. Multipart Requests. Multipart requests combine one or more sets of data into a single body,...
Read more >How do I specify a multifile upload in OpenAPI?
I am trying to create an OpenAPI JSON input for the OpenAPI 3.0 UI for the multipart file upload. Here is what I...
Read more >File upload on the V3 spec through multipart/form-data is ...
Run the function app. Access the OpenAPI document through http://localhost:7071/api/openapi/v3.json; Confirm whether it renders correctly.
Read more >OpenAPI spec with multipart/form-data
We created an API from openapi spec. This is very simple spec with one path. But Select file field doesn't exists on the...
Read more >Unable to edit the openAPI specification for multipart/form- ...
Hi, I have an API that use the multipart/form-data request, but I can't edit it in openAPI Specification. Is it not supported yet?...
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
This workaround can be used in the client partial class:
I’m also having this issue with any IFormFile inputs on the controller. This worked fine with the Swagger 2.0 spec.
When generating a client for a multipart_file_upload using Swagger 2.0 spec a
FileParameter(Stream data, string fileName, string contentType)
would be generated and then within the client the following code would be generated for handling the boundaries:Where
file
is of type FileParamter. This does not happen when generating code for the same endpoint using OpenApi3, instead, we do not generate a FileParameter class and pass in a Stream directly to the client api method. This means that the receiving server responds with a “missing content-type boundary”.Let me know if I can provide any more information.