RicoSuter/NSwag

[C# Client] Binary string parameters not supported?

Open

#1,824 opened on Dec 13, 2018

View on GitHub
 (9 comments) (4 reactions) (0 assignees)C# (1,189 forks)batch import
format: OpenAPI 3help wantedproject: NJsonSchema.CodeGeneration.CSharpproject: NJsonSchema.CodeGeneration.TypeScripttype: enhancement

Repository metrics

Stars
 (6,291 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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?

Contributor guide