Skip to content

[C#][csharp-netcore] Error responses do not correctly deserialise #3473

@rizwansaeed

Description

@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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions