OpenAPITools / OpenAPITools/openapi-generator
[BUG][csharp][csharp-netcore] HttpClient is generated with an Obsolete warning.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The ApiClient is generated using an as Obsolete marked property that causes warnings in the generated project.
//'HttpRequestMessage.Properties' is obsolete: 'Use Options instead.'
if (options.Cookies != null && options.Cookies.Count > 0)
{
request.Properties["CookieContainer"] = options.Cookies;
}
https://github.com/dotnet/runtime/issues/34168
openapi-generator version
5.2.1 (technically Docker Image Tag: latest-release)
OpenAPI declaration file content or url
Haven't tried it, but should happen with PetShop.yaml.
Generation Details
csharp-netcore option "library" set to "httpclient".
Steps to reproduce
- Generate csharp-netcore client with httpclient setting.
- Compile generate code.
- Get warning.
Related issues/PRs
Suggest a fix
The change seem to be a year old, but I could not find a correct new implementation. ... so ... ¯\_(ツ)_/¯
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 with modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache at line 389 and review the generated HttpRequestMessage usage. Generate a csharp-netcore client with the httpclient library, compile it, and confirm the warning is removed while cookie handling still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100