Skip to content

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

@jornhd

Description

@jornhd

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,

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions