CSharp Client "Content-Disposition"-Header in request is generated invalid
I generated a CSharp openApi client with a file upload to support chunked file uploads.
The CSharp client-generated Content-Disposition is not inserted into the request header as expected.
It seams to be dropped by request_.Headers.TryAddWithoutValidation(..., by replacing it with request_.Headers.Add(... throws an AggregateException.
System.AggregateException: "One or more errors occurred. (Misused header name, 'Content-Disposition'. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.)"
Example OpenAPI Part of for endpoint:
"post": { "summary": "Upload file segments.", "operationId": "Endpoints_TestContentDispositionHeader", "parameters": [{ "name": "Content-Disposition", "in": "header", "description": "Name of attachment", "required": true, "schema": { "type": "string" }, "example": "attachment; filename='file.ext'" }, { "name": "X-Session-ID", "in": "header", "description": "Session ID", "required": true, "schema": { "type": "string" }, "example": 123456789 }, { "name": "X-Content-Range", "in": "header", "description": "Byte Range of uploaded segement (segmentStart-segmentEnd/totalFileSize)", "required": true, "schema": { "type": "string" }, "example": "bytes 0-10000/200000" }], "requestBody": { "description": "Segment of the file, corresponding to the range that was specified in \"X-Content-Range\" headers ", "content": { "application/octet-stream": { "schema": { "type": "string", "format": "binary" } } } }, "responses": { "200": { "description": "The comparison result.", "content": { "application/json": { "schema": { "type": "string" } } } } } }
Source: RicoSuter/NSwag