OpenAPITools / OpenAPITools/openapi-generator

[REQ][csharp-netcore] httpclient library please remove old constructors

Open
#10,001 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

I would like to have a setting to not create old constructors when generating client for csharp-netcore httpclient library.
Currently I have large existing code base and we are migrating to .net core and same time converting our generated API clients to use http client based code. Because RestSharp in .net core may cause port exhaustion issue. Now when migrating the existing codebase it is difficult to find all the areas which need to be changed because the new generated code compiles the same as previous restsharp client did, however it would fail runtime to socket exhaustion issue.

Describe the solution you'd like

I would like to have an option or change http client library generator so that it does not generate constructors where its not required to give http client as parameter.

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache#L192-L217

Describe alternatives you've considered

I have considered manually changing the generated code by commenting out these constructors but its problematic when we re-generate the code.

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 with modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache, especially lines 192–217, to understand which constructors are generated for the csharp-netcore httpclient library. Add an option or generator behavior that omits constructors not requiring an HttpClient parameter, and verify that regeneration no longer produces those constructors.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.