Open KoeMai opened 2 years ago
well, it's not affecting only Content-Disposition
header, but rather all content related headers. Generated client code is trying to add content headers into HttpRequestMessage.Headers
collection, which takes no real effect. Content headers should be added into HttpRequestMessage.Headers.Content.Headers
collection:
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 byrequest_.Headers.TryAddWithoutValidation(...
, by replacing it withrequest_.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" } } } } } }