OpenAPITools / OpenAPITools/openapi-generator

[BUG][C#][Client: C-Sharp] Calling xHttpWithInfo methods do not return headers when 4xx responses are returned

Open
#4,388 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Calling a xHttpWithInfo method that returns a response in the 200 range returns an ApiResponse containing the domain model and the returned headers

However, if a response in the 400 range is received no headers are returned, only an ApiException.

This becomes an issue when a 429 response is received and Retry-After header is returned as there is no way to obtain this (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After)

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 -c config_file

{
  "packageName": "Lusid.Sdk",
  "sourceFolder": ".",
  "targetFramework": "v5.0",
  "useDateTimeOffset": true,
  "netCoreProjectFile": true,
  "returnICollection": true,
  "packageVersion": "0.10.841"
}
Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/issues/3473

Suggest a fix
  1. Return an ApiResponse with the ApiException in the Data field

or

  1. Return the headers in the ApiException

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the generated C# xHttpWithInfo methods and ApiException handling, then inspect the C# generator templates used by the command in the issue. Verify how 4xx response headers, especially Retry-After, are exposed and confirm the chosen ApiResponse or ApiException behavior against the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.