RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.61k stars 1.22k forks source link

NSwag generated C# clients fail to set Content-Language header as it must be set on Content headers #4855

Open kmgallahan opened 2 months ago

kmgallahan commented 2 months ago

NSwag generated code from openapi specifications that indicate the Content-Language header is required for a POST request tries to do the following:

request_.Headers.TryAddWithoutValidation("Content-Language", ConvertToString(content_Language, System.Globalization.CultureInfo.InvariantCulture));

Which always fails because Content-Language is not a valid header there. Rather, it must be added to the content headers:

request_.Content = content_;
request_.Content.Headers.TryAddWithoutValidation("Content-Language", ConvertToString(content_Language, System.Globalization.CultureInfo.InvariantCulture));