From 43d1c5bffc2e32c2dcc9ed1f51ec4c213cdf686f Mon Sep 17 00:00:00 2001 From: lunat Date: Tue, 5 Jul 2016 14:42:43 +0200 Subject: [PATCH 1/3] CSharp client header problem CSharp client may cause an error adding an header because the header list is static. Added a check and a function tu set up the ApiKey --- .../main/resources/csharp/Configuration.mustache | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache index 5ce03342baa..d2d7a9ad34b 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache @@ -158,9 +158,24 @@ namespace {{packageName}}.Client /// public void AddDefaultHeader(string key, string value) { + if (_defaultHeaderMap.ContainsKey(key)) + _defaultHeaderMap.Remove(key); _defaultHeaderMap.Add(key, value); } + /// + /// Add Api Key. + /// + /// Api Key name. + /// Api Key value. + /// + public void AddApiKeyPrefix(string key, string value) + { + if (ApiKeyPrefix.ContainsKey(key)) + ApiKeyPrefix.Remove(key); + ApiKeyPrefix.Add(key, value); + } + /// /// Gets or sets the HTTP user agent. /// From 41bab483e04607b339e9bfdf57410607ea8d42cd Mon Sep 17 00:00:00 2001 From: lunat Date: Tue, 19 Jul 2016 12:45:52 +0200 Subject: [PATCH 2/3] Issue #3295 [csharp] header problem due to static method for adding header --- .../main/resources/csharp/Configuration.mustache | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache index d2d7a9ad34b..2932c59eb10 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache @@ -164,11 +164,23 @@ namespace {{packageName}}.Client } /// - /// Add Api Key. + /// Add Api Key Header. /// /// Api Key name. /// Api Key value. /// + public void AddApiKey(string key, string value) + { + if (ApiKey.ContainsKey(key)) + ApiKey.Remove(key); + ApiKey.Add(key, value); + } + + /// + /// Sets the API key prefix. + /// + /// Api Key name. + /// Api Key value. public void AddApiKeyPrefix(string key, string value) { if (ApiKeyPrefix.ContainsKey(key)) @@ -176,6 +188,7 @@ namespace {{packageName}}.Client ApiKeyPrefix.Add(key, value); } + /// /// Gets or sets the HTTP user agent. /// From 92e8efde1a72d367c37716d3c1453d15d54a90ec Mon Sep 17 00:00:00 2001 From: lunat Date: Tue, 19 Jul 2016 14:37:03 +0200 Subject: [PATCH 3/3] Csharp api key header issue 3295 --- .../src/main/resources/csharp/Configuration.mustache | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache index 2932c59eb10..b8cd6c1b330 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache @@ -169,14 +169,14 @@ namespace {{packageName}}.Client /// Api Key name. /// Api Key value. /// - public void AddApiKey(string key, string value) + public void AddApiKey(string key, string value) { if (ApiKey.ContainsKey(key)) ApiKey.Remove(key); ApiKey.Add(key, value); } - /// + /// /// Sets the API key prefix. /// /// Api Key name. @@ -188,7 +188,6 @@ namespace {{packageName}}.Client ApiKeyPrefix.Add(key, value); } - /// /// Gets or sets the HTTP user agent. ///