diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
index 707ce9eb5602..b8b9fc7a5a18 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
@@ -19,23 +19,56 @@ namespace {{packageName}}.Client
public class ApiClient
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class
+ /// with default configuration and base path ({{basePath}}).
+ ///
+ public ApiClient()
+ {
+ Configuration = Configuration.Default;
+ RestClient = new RestClient("{{basePath}}");
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with default base path ({{basePath}}).
+ ///
+ /// An instance of Configuration.
+ public ApiClient(Configuration config = null)
+ {
+ if (config == null)
+ Configuration = Configuration.Default;
+ else
+ Configuration = config;
+
+ RestClient = new RestClient("{{basePath}}");
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with default configuration.
///
/// The base path.
- public ApiClient(String basePath="{{basePath}}")
+ public ApiClient(String basePath = "{{basePath}}")
{
if (String.IsNullOrEmpty(basePath))
throw new ArgumentException("basePath cannot be empty");
RestClient = new RestClient(basePath);
+ Configuration = Configuration.Default;
}
///
/// Gets or sets the default API client for making HTTP calls.
///
/// The default API client.
- public static ApiClient Default = new ApiClient();
+ public static ApiClient Default = new ApiClient(Configuration.Default);
+ ///
+ /// Gets or sets the Configuration.
+ ///
+ /// An instance of the Configuration.
+ public Configuration Configuration { get; set; }
+
///
/// Gets or sets the RestClient.
///
diff --git a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache
index 44459e54440e..440288a48327 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache
@@ -109,13 +109,13 @@ namespace {{packageName}}.Client
return apiKeyValue;
}
- private static string _tempFolderPath = Path.GetTempPath();
+ private string _tempFolderPath = Path.GetTempPath();
///
/// Gets or sets the temporary folder path to store the files downloaded from the server.
///
/// Folder path.
- public static String TempFolderPath
+ public String TempFolderPath
{
get { return _tempFolderPath; }
@@ -141,7 +141,7 @@ namespace {{packageName}}.Client
private const string ISO8601_DATETIME_FORMAT = "o";
- private static string _dateTimeFormat = ISO8601_DATETIME_FORMAT;
+ private string _dateTimeFormat = ISO8601_DATETIME_FORMAT;
///
/// Gets or sets the the date time format used when serializing in the ApiClient
@@ -151,7 +151,7 @@ namespace {{packageName}}.Client
/// No validation is done to ensure that the string you're providing is valid
///
/// The DateTimeFormat string
- public static String DateTimeFormat
+ public String DateTimeFormat
{
get
{
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
index 9ab779c9f4b6..ba58eeac9e0e 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
@@ -6,7 +6,6 @@ using RestSharp;
using IO.Swagger.Client;
using IO.Swagger.Model;
-
namespace IO.Swagger.Api
{
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs
index db82bf8e6440..a9e9d6e9b741 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs
@@ -6,7 +6,6 @@ using RestSharp;
using IO.Swagger.Client;
using IO.Swagger.Model;
-
namespace IO.Swagger.Api
{
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs
index ac4f138c568b..5502fe15da17 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs
@@ -6,7 +6,6 @@ using RestSharp;
using IO.Swagger.Client;
using IO.Swagger.Model;
-
namespace IO.Swagger.Api
{
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs
index faf688b55853..58ade0637180 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs
@@ -19,23 +19,56 @@ namespace IO.Swagger.Client
public class ApiClient
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class
+ /// with default configuration and base path (http://petstore.swagger.io/v2).
+ ///
+ public ApiClient()
+ {
+ Configuration = Configuration.Default;
+ RestClient = new RestClient("http://petstore.swagger.io/v2");
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with default base path (http://petstore.swagger.io/v2).
+ ///
+ /// An instance of Configuration.
+ public ApiClient(Configuration config = null)
+ {
+ if (config == null)
+ Configuration = Configuration.Default;
+ else
+ Configuration = config;
+
+ RestClient = new RestClient("http://petstore.swagger.io/v2");
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with default configuration.
///
/// The base path.
- public ApiClient(String basePath="http://petstore.swagger.io/v2")
+ public ApiClient(String basePath = "http://petstore.swagger.io/v2")
{
if (String.IsNullOrEmpty(basePath))
throw new ArgumentException("basePath cannot be empty");
RestClient = new RestClient(basePath);
+ Configuration = Configuration.Default;
}
///
/// Gets or sets the default API client for making HTTP calls.
///
/// The default API client.
- public static ApiClient Default = new ApiClient();
+ public static ApiClient Default = new ApiClient(Configuration.Default);
+ ///
+ /// Gets or sets the Configuration.
+ ///
+ /// An instance of the Configuration.
+ public Configuration Configuration { get; set; }
+
///
/// Gets or sets the RestClient.
///
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs
index fcdc16f44db5..588b106dec9a 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs
@@ -109,13 +109,13 @@ namespace IO.Swagger.Client
return apiKeyValue;
}
- private static string _tempFolderPath = Path.GetTempPath();
+ private string _tempFolderPath = Path.GetTempPath();
///
/// Gets or sets the temporary folder path to store the files downloaded from the server.
///
/// Folder path.
- public static String TempFolderPath
+ public String TempFolderPath
{
get { return _tempFolderPath; }
@@ -141,7 +141,7 @@ namespace IO.Swagger.Client
private const string ISO8601_DATETIME_FORMAT = "o";
- private static string _dateTimeFormat = ISO8601_DATETIME_FORMAT;
+ private string _dateTimeFormat = ISO8601_DATETIME_FORMAT;
///
/// Gets or sets the the date time format used when serializing in the ApiClient
@@ -151,7 +151,7 @@ namespace IO.Swagger.Client
/// No validation is done to ensure that the string you're providing is valid
///
/// The DateTimeFormat string
- public static String DateTimeFormat
+ public String DateTimeFormat
{
get
{
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs
index 03551f9492bc..d9cb6b21005d 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs
@@ -7,8 +7,6 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
-
-
namespace IO.Swagger.Model
{
@@ -124,6 +122,4 @@ namespace IO.Swagger.Model
}
}
-
-
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs
index 1d214430ec86..2191707bd091 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs
@@ -7,8 +7,6 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
-
-
namespace IO.Swagger.Model
{
@@ -189,6 +187,4 @@ namespace IO.Swagger.Model
}
}
-
-
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs
index ab60577e85af..10c44fb46a7b 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs
@@ -7,8 +7,6 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
-
-
namespace IO.Swagger.Model
{
@@ -189,6 +187,4 @@ namespace IO.Swagger.Model
}
}
-
-
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs
index cf77c2470b2d..93210505bf0f 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs
@@ -7,8 +7,6 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
-
-
namespace IO.Swagger.Model
{
@@ -124,6 +122,4 @@ namespace IO.Swagger.Model
}
}
-
-
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs
index eca977c3b183..1fbd17da993a 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs
@@ -7,8 +7,6 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
-
-
namespace IO.Swagger.Model
{
@@ -221,6 +219,4 @@ namespace IO.Swagger.Model
}
}
-
-
}
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs
index adf59e0ae0ca..f0232c330f04 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs
@@ -11,7 +11,7 @@ namespace SwaggerClientTest.TestApiClient
public void TearDown()
{
// Reset to default, just in case
- Configuration.DateTimeFormat = "o";
+ Configuration.Default.DateTimeFormat = "o";
}
[Test ()]
@@ -29,28 +29,34 @@ namespace SwaggerClientTest.TestApiClient
}
[Test ()]
- public void TestParameterToString_DateTime ()
- {
- ApiClient api = new ApiClient();
+ public void TestParameterToStringForDateTime ()
+ {
+ ApiClient api = new ApiClient ();
- // test datetime
- DateTime dateUtc = DateTime.Parse("2008-04-10T13:30:00.0000000z", null, System.Globalization.DateTimeStyles.RoundtripKind);
- Assert.AreEqual("2008-04-10T13:30:00.0000000Z", api.ParameterToString(dateUtc));
+ // test datetime
+ DateTime dateUtc = DateTime.Parse ("2008-04-10T13:30:00.0000000z", null, System.Globalization.DateTimeStyles.RoundtripKind);
+ Assert.AreEqual ("2008-04-10T13:30:00.0000000Z", api.ParameterToString (dateUtc));
- // test datetime with no timezone
- DateTime dateWithNoTz = DateTime.Parse("2008-04-10T13:30:00.000", null, System.Globalization.DateTimeStyles.RoundtripKind);
- Assert.AreEqual("2008-04-10T13:30:00.0000000", api.ParameterToString(dateWithNoTz));
+ // test datetime with no timezone
+ DateTime dateWithNoTz = DateTime.Parse ("2008-04-10T13:30:00.000", null, System.Globalization.DateTimeStyles.RoundtripKind);
+ Assert.AreEqual ("2008-04-10T13:30:00.0000000", api.ParameterToString (dateWithNoTz));
+ }
+ // The test below only passes when running at -04:00 timezone
+ [Ignore ()]
+ public void TestParameterToStringWithTimeZoneForDateTime ()
+ {
+ ApiClient api = new ApiClient ();
// test datetime with a time zone
DateTime dateWithTz = DateTime.Parse("2008-04-10T13:30:00.0000000-04:00", null, System.Globalization.DateTimeStyles.RoundtripKind);
Assert.AreEqual("2008-04-10T13:30:00.0000000-04:00", api.ParameterToString(dateWithTz));
}
[Test ()]
- public void TestParameterToString_DateTime_WithUFormat ()
+ public void TestParameterToStringForDateTimeWithUFormat ()
{
// Setup the DateTimeFormat across all of the calls
- Configuration.DateTimeFormat = "u";
+ Configuration.Default.DateTimeFormat = "u";
ApiClient api = new ApiClient();
// test datetime
@@ -59,10 +65,10 @@ namespace SwaggerClientTest.TestApiClient
}
[Test ()]
- public void TestParameterToString_DateTime_WithCustomFormat ()
+ public void TestParameterToStringForDateTimeWithCustomFormat ()
{
// Setup the DateTimeFormat across all of the calls
- Configuration.DateTimeFormat = "dd/MM/yy HH:mm:ss";
+ Configuration.Default.DateTimeFormat = "dd/MM/yy HH:mm:ss";
ApiClient api = new ApiClient();
// test datetime
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs
index c72a00066918..2ea6785529a9 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs
@@ -13,7 +13,7 @@ namespace SwaggerClientTest.TestConfiguration
public void TearDown ()
{
// Reset to default, just in case
- Configuration.DateTimeFormat = "o";
+ Configuration.Default.DateTimeFormat = "o";
}
[Test ()]
@@ -44,15 +44,15 @@ namespace SwaggerClientTest.TestConfiguration
{
// Should default to the Round-trip Format Specifier - "o"
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
- Assert.AreEqual("o", Configuration.DateTimeFormat);
+ Assert.AreEqual("o", Configuration.Default.DateTimeFormat);
}
[Test ()]
public void TestDateTimeFormat_UType()
{
- Configuration.DateTimeFormat = "u";
+ Configuration.Default.DateTimeFormat = "u";
- Assert.AreEqual("u", Configuration.DateTimeFormat);
+ Assert.AreEqual("u", Configuration.Default.DateTimeFormat);
}
[Test ()]
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
index a438e1039547..dbeb4f0ebadc 100755
Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll differ
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb
index 79928c469eef..8815d6d145c6 100644
Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb differ
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt
index 3e55ab909656..7d68ff048e5d 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt
+++ b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt
@@ -1,4 +1,5 @@
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
+/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.swagger-logo.png
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
index a438e1039547..dbeb4f0ebadc 100755
Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll differ
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb
index 79928c469eef..8815d6d145c6 100644
Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb differ