Description
When generating a csharp client the "Accept" header is set differently for the sync and async version of the API. In our case this leads to the api using "application/xml" for the async variant and "application/json" for the sync variant.
I suspect the main reason for this is that the lines
var localVarAccept = {{packageName}}.Client.ClientUtils.SelectHeaderAccept(_accepts);
if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
are not used for the async template.
This only happens if "application/xml" occurs later than "application/json" in the array of supported_accept media types.
openapi-generator version
4.3.1
OpenAPI declaration file content or url
https://gist.github.com/mh03r932/8d2e7c390169e3cec49b62928e0f102a
Command line used for generation
Client was generated using the maven plugin with the following config
<configOptions>
<packageName>FeWoFeondi.RestApiClient</packageName>
<targetFramework>netstandard2.1</targetFramework>
<netCoreProjectFile>true</netCoreProjectFile>
<optionalEmitDefaultValues>true</optionalEmitDefaultValues>
<releaseNote>This Code was generated using OpenApiTools https://github.com/OpenAPITools/</releaseNote>
<optionalAssemblyInfo>false</optionalAssemblyInfo>
</configOptions>
Steps to reproduce
- Generate any client that supports application/xml and application/json as accept mediatypes
- make sure the "application/xml" media type is last entry in the _accepts String array in the generated api-class you are testing.
- check the sent headers dependeing on wether the async or the sync variant is used
Suggest a fix
Add the following two lines after Line 426 in api.mustache
var localVarAccept = {{packageName}}.Client.ClientUtils.SelectHeaderAccept(_accepts); if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
Basic pull-request #mh03r932#1
Description
When generating a csharp client the "Accept" header is set differently for the sync and async version of the API. In our case this leads to the api using "application/xml" for the async variant and "application/json" for the sync variant.
I suspect the main reason for this is that the lines
are not used for the async template.
This only happens if "
application/xml" occurs later than "application/json" in the array of supported_accept media types.openapi-generator version
4.3.1
OpenAPI declaration file content or url
https://gist.github.com/mh03r932/8d2e7c390169e3cec49b62928e0f102a
Command line used for generation
Client was generated using the maven plugin with the following config
Steps to reproduce
Suggest a fix
Add the following two lines after Line 426 in api.mustache
var localVarAccept = {{packageName}}.Client.ClientUtils.SelectHeaderAccept(_accepts); if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);Basic pull-request #mh03r932#1