OpenAPITools / OpenAPITools/openapi-generator

[REQ][csharp-netcore] Extract fixed Client code bits to library

Open
#2,925 1 comment 1 reaction 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

Problem

Within one of my services, I access multiple APIs. When generating code for these APIs, a Client package is generated for each of them. This package contains classes that only vary in a few comment lines and default values for Configuration parameters. We end up with many classes/interfaces such as HttpMethod, that are isomorphic yet incompatible across Client packages.

Proposal

  1. Put the Client package under a fixed package (OpenAPI?) instead of the parameterised one.
  2. Extract that package into a library and eliminate it as part of the code-generation output
  3. Import the library from the generated project file
  4. Generate a [API]Configuration class that extends the current Client.Configuration class and provides the generated defaults for the upper class, such as basePath.

Alternatively

  1. Introduce a separate clientPackage code-gen parameter that allows overriding the package where the Client files will be placed
  2. Eliminate the API specific comments in Client package, as well as the default values in the Configuration class
  3. Generate a [API]Configuration class that extends ${clientPackage}.Configuration class and provides the generated defaults for the upper class, such as basePath.

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 examining the C#/.NET Core generator output, focusing on the generated Client package, its Configuration class, and the generated project file. Compare the proposed fixed-library and clientPackage alternatives, then define completion as shared fixed Client code, generated API-specific configuration defaults, and correct library imports without duplicating Client code.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.