Hi.
The OpenAPI 3 specification specifies that files can be sent in a request by declaring that a parameters is of the type string with the format binary: https://swagger.io/docs/specification/describing-request-body/file-upload/
The proposed way to send a single file is as shown below:
requestBody:
content:
image/png:
schema:
type: string
format: binary
When generating a C# client, I would expect to give some sort of Stream (e.g. FileStream) or a byte[], but the client wants me to supply a normal string. From what I can understand, this is not what the OpenAPI spec means with "binary string". Are strings of format binary not currently supported? Is support planned?
This is currently not implemented
@RSuter Ok, thank you for your quick response. Would you mind listing roughly what needs to be done to support it? I am interested in taking a look at it, but no promises.
Either here:
... but you also need to check how this property is handled in the liquid templates and see whether it has the correct behavior.
or here:
If the behavior is different then the existing one, add a new bool property in the model
Also the IsBody property (your case) may need a change in behavior
Thanks for your help.
I have a similar issue. I need to post multi-part binary files.
Did you solve this issue or find a workaround?
Thanks!!
@gilzig I have not found the time to implement support for this in NSwag.
My temporary solution is to build the request by hand, using Flurl (https://flurl.io/docs/fluent-http/)
and the PostMultipartAsync method.
I still would like to implement this in NSwag, but I don't think I can find the time quite yet, unfortunately.
Can I assume that this is also unimplemented for C# controllers? I see that string/binary multipart specs in openapi3 result in simple string JSON body objects in the controller code and not in any stream/IFile code?
Most helpful comment
@RSuter Ok, thank you for your quick response. Would you mind listing roughly what needs to be done to support it? I am interested in taking a look at it, but no promises.