swagger-api / swagger-api/swagger-codegen
[dotnet core] [csharp-dotnet2] Add a method to edit default headers
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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