swagger-api / swagger-api/swagger-codegen

c# client : response headers invalid parsing

Open
#6,389 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: C-Sharp Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

The header collection is wrongly populated.

For instance:

https://dev.fitbit.com/docs/explore/#/Activity/get_1_user___activities_date__date__json

is generated as:

public ApiResponse<Object> v1UserActivitiesDateDateJsonGetWithHttpInfo (string date) { ... return new ApiResponse<Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()), null); }

I simply replaced x.Value.ToString() with x => String.Join(",", x.Value.ToArray()) to solve the problem for now:

public ApiResponse<Object> v1UserActivitiesDateDateJsonGetWithHttpInfo (string date) { ... return new ApiResponse<Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Key, x => String.Join(",", x.Value.ToArray())), null); }

I'm running swagger-codegen 2.2.3 on MacOSX installed with Homebrew.
To reproduce the problem, generate a csharp client api with the following command:

swagger-codegen generate -i https://dev.fitbit.com/docs/explore/fitbit-web-api.swagger.json -l csharp

Related issues : #6387 #6388

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

Reproduce the issue with the provided swagger-codegen command and inspect the generated C# client's response-header conversion in v1UserActivitiesDateDateJsonGetWithHttpInfo. Confirm that headers with multiple values are preserved rather than collapsed by ToString(), then verify the generated client handles the Fitbit API response correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.