swagger-api / swagger-api/swagger-codegen

[dotnet core] [csharp-dotnet2] Add a method to edit default headers

Open
#10,083 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Similar to the configuration class from c#, it sould be possible to set the default headers for each HTTP request.
At the moment adding deafult header will cause duplicates, beacause there is no way to remove the previous header.

Swagger-codegen version

CodeGen version: 3

Related issues/PRs

https://github.com/swagger-api/swagger-codegen/issues/6976

Suggest a fix/enhancement

fix duplicate problem:

public ApiClient AddDefaultHeader(string name, string value) {
        if(defaultHeaders.ContainsKey(name))
            defaultHeaders.Remove(name);
        defaultHeaders.Add(name, value);
        return this;
    }

or add something like

public void SetDefaultHeader(HttpHeaders headers){
       defaultHeaders = headers;
}

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 locating the generated C# ApiClient and its AddDefaultHeader implementation, then review related issue 6976. Confirm how defaultHeaders currently handles repeated names and define done as providing a way to replace an existing default header without duplicates, with coverage for the chosen behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.