OpenAPITools / OpenAPITools/openapi-generator
[BUG] [CSharp] httpclient does not support Options, only supports obsolete HttpRequestMessage.Properties
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)
Using openapi-generator to generate csharp clients with the HttpClient library ends up generating code that uses the obsolete HttpRequestMessage.Properties which was deprecated way back in .NET5
It should use the recommended Options instead.
Here's the warnings outputted by Visual Studio 2022:
1>C:\MyApi\Client\ApiClient.cs(418,17,418,35): warning CS0618: 'HttpRequestMessage.Properties' is obsolete: 'HttpRequestMessage.Properties has been deprecated. Use Options instead.'
1>C:\MyApi\Client\ApiClient.cs(505,39,505,53): warning CS0618: 'HttpRequestMessage.Properties' is obsolete: 'HttpRequestMessage.Properties has been deprecated. Use Options instead.'
1>C:\MyApi\Client\ApiClient.cs(505,87,505,101): warning CS0618: 'HttpRequestMessage.Properties' is obsolete: 'HttpRequestMessage.Properties has been deprecated. Use Options instead.'
Description
openapi-generator version
7.8.0
OpenAPI declaration file content or url
Here's the contents of the config file
generatorName: csharp
sourceFolder: Src
additionalProperties:
library: httpclient
targetFramework: net8.0
Generation Details
Steps to reproduce
- generate a client with csharp + httpclient + .NET8.0 using the openapi generator config pasted above,
- check the resulting code.
Related issues/PRs
- #12691
Suggest a fix
- Add support
Options, - add a csharp config option to toggle between
HttpRequestMessage.PropertiesandOptions, setHttpRequestMessage.Propertiesas default.
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 generating the C# httpclient client with the provided config and inspect the generated ApiClient.cs locations cited in the warning output. Read docs/generators/csharp.md and related issue #12691 to understand the intended configuration behavior. Done means the generated .NET 8 client uses the supported request metadata API and no longer emits the reported obsolete-property warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100