OpenAPITools / OpenAPITools/openapi-generator

[BUG][csharp-netcore] ClientCertificates are not merged with GlobalConfiguration in api constructors

Open
#6,940 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • [ x ] Have you provided a full/minimal spec to reproduce the issue?
  • [ n/a ] Have you validated the input using an OpenAPI validator (example)?
  • [ x ] What's the version of OpenAPI Generator used?
  • [ x ] Have you search for related issues/PRs?
  • [ n/a ] What's the actual output vs expected output?
  • [ n/a ] [Optional] Bounty to sponsor the fix (example)
Description

The configuration property ClientCertificates added with #5328 is lost in most of the api constructors. These constructors calls method Client.Configuration.MergeConfigurations() to merge the given configuration object with the global configuration. As this method does not handle the ClientCertificates property, the given configuration's certificate collection is lost.

openapi-generator version

4.3.1

OpenAPI declaration file content or url

n/a

Command line used for generation

openapi-generator generate -i SomeApi.json -o SomeApi\output -g csharp-netcore --package-name SomeApi

Steps to reproduce
var config = new Configuration { ClientCertificates = new X509CertificateCollection { new X509Certificate2() } };
var api = new SomeApi(config);

Assert.NotNull(api.Configuration.ClientCertificates);
Related issues/PRs
Suggest a fix

Add merging of the ClientCertificates property in line 411 of modules/openapi-generator/src/main/resources/csharp-netcore/Configuration.mustache:
ClientCertificates = second.ClientCertificates ?? first.ClientCertificates,

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 in modules/openapi-generator/src/main/resources/csharp-netcore/Configuration.mustache around line 411 and inspect MergeConfigurations. Reproduce the issue with the shown Configuration and SomeApi constructor, then verify that the generated client's ClientCertificates collection is retained after merging and run the relevant C# generator tests if available.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.