[C#][csharp-netcore] Error responses do not correctly deserialise
Created by: rizwansaeed
Description
If an API returns a response in the 400 range e.g. 404 along with a body, it attempts to deserialise into the target model object rather than ApiException
resulting in a deserialisation error and loses the body of the response
openapi-generator version
4.0.3
OpenAPI declaration file content or url
https://fbn-prd.lusid.com/api/swagger/v0/swagger.json
Command line used for generation
java -jar openapi-generator-cli.jar generate -g csharp-netcore -c config.json
{
"packageName": "Lusid.Sdk",
"sourceFolder": ".",
"targetFramework": "netcoreapp2.0",
"useDateTimeOffset": true,
"netCoreProjectFile": true,
"returnICollection": true,
"packageVersion": "0.10.482"
}
Suggest a fix
The issue looks related to https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache#L126 but an ApiException
would needed to be propagated back up the cll chain