From 9d76d39c006554ca8150fbd8c5e26c6e11108b5a Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 20 Nov 2015 16:15:19 +0800 Subject: [PATCH] update basic auth to allow only username/password --- .../src/main/resources/csharp/ApiClient.mustache | 2 +- .../csharp/SwaggerClientTest/SwaggerClientTest.userprefs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache index 8af5250c471..bac6fd02a69 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache @@ -331,7 +331,7 @@ namespace {{packageName}}.Client { queryParams["{{keyParamName}}"] = apiKeyValue; }{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}} - if (!String.IsNullOrEmpty(Configuration.Username) && !String.IsNullOrEmpty(Configuration.Password)) + if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password)) { headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password); }{{/isBasic}}{{#isOAuth}} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index 05585bff932..5f6ec1cf979 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -2,7 +2,7 @@ - + @@ -26,4 +26,4 @@ - \ No newline at end of file +