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 +