diff --git a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache index b5ebd08ba8..7062a73c1e 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache @@ -24,15 +24,16 @@ namespace {{packageName}}.Client /// Dictionary of API key prefix /// Temp folder path /// DateTime format string - public Configuration(ApiClient apiClient, - Dictionary defaultHeader, - string username, - string password, - string accessToken, - Dictionary apiKey, - Dictionary apiKeyPrefix, - string tempFolderPath, - string dateTimeFormat + public Configuration(ApiClient apiClient = null, + Dictionary defaultHeader = null, + string username = null, + string password = null, + string accessToken = null, + Dictionary apiKey = null, + Dictionary apiKeyPrefix = null, + string tempFolderPath = null, + string dateTimeFormat = null, + int timeout = 100000 ) { if (apiClient == null) @@ -43,19 +44,24 @@ namespace {{packageName}}.Client Username = username; Password = password; AccessToken = accessToken; - ApiKey = apiKey; - ApiKeyPrefix = apiKeyPrefix; + + if (defaultHeader != null) + DefaultHeader = defaultHeader; + if (apiKey != null) + ApiKey = apiKey; + if (apiKeyPrefix != null) + ApiKeyPrefix = apiKeyPrefix; TempFolderPath = tempFolderPath; DateTimeFormat = dateTimeFormat; - + Timeout = timeout; } /// /// Initializes a new instance of the Configuration class. /// /// Api client. - public Configuration(ApiClient apiClient=null) + public Configuration(ApiClient apiClient) { if (apiClient == null) ApiClient = ApiClient.Default; @@ -75,20 +81,39 @@ namespace {{packageName}}.Client /// Configuration. public static Configuration Default = new Configuration(); + /// + /// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds. + /// + /// Timeout. + public int Timeout + { + get { return ApiClient.RestClient.Timeout; } + + set + { + ApiClient.RestClient.Timeout = value; + } + } + /// /// Gets or sets the default API client for making HTTP calls. /// /// The API client. public ApiClient ApiClient; - private readonly Dictionary _defaultHeaderMap = new Dictionary(); + private Dictionary _defaultHeaderMap = new Dictionary(); /// - /// Gets the default header. + /// Gets or sets the default header. /// public Dictionary DefaultHeader { get { return _defaultHeaderMap; } + + set + { + _defaultHeaderMap = value; + } } /// 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 4537144f93..e7334aa160 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 db82bf8e64..a9e9d6e9b7 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 ac4f138c56..5502fe15da 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/Configuration.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs index 13d16c9ce5..000b8893cd 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 @@ -24,15 +24,16 @@ namespace IO.Swagger.Client /// Dictionary of API key prefix /// Temp folder path /// DateTime format string - public Configuration(ApiClient apiClient, - Dictionary defaultHeader, - string username, - string password, - string accessToken, - Dictionary apiKey, - Dictionary apiKeyPrefix, - string tempFolderPath, - string dateTimeFormat + public Configuration(ApiClient apiClient = null, + Dictionary defaultHeader = null, + string username = null, + string password = null, + string accessToken = null, + Dictionary apiKey = null, + Dictionary apiKeyPrefix = null, + string tempFolderPath = null, + string dateTimeFormat = null, + int timeout = 100000 ) { if (apiClient == null) @@ -43,19 +44,24 @@ namespace IO.Swagger.Client Username = username; Password = password; AccessToken = accessToken; - ApiKey = apiKey; - ApiKeyPrefix = apiKeyPrefix; + + if (defaultHeader != null) + DefaultHeader = defaultHeader; + if (apiKey != null) + ApiKey = apiKey; + if (apiKeyPrefix != null) + ApiKeyPrefix = apiKeyPrefix; TempFolderPath = tempFolderPath; DateTimeFormat = dateTimeFormat; - + Timeout = timeout; } /// /// Initializes a new instance of the Configuration class. /// /// Api client. - public Configuration(ApiClient apiClient=null) + public Configuration(ApiClient apiClient) { if (apiClient == null) ApiClient = ApiClient.Default; @@ -75,20 +81,39 @@ namespace IO.Swagger.Client /// Configuration. public static Configuration Default = new Configuration(); + /// + /// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds. + /// + /// Timeout. + public int Timeout + { + get { return ApiClient.RestClient.Timeout; } + + set + { + ApiClient.RestClient.Timeout = value; + } + } + /// /// Gets or sets the default API client for making HTTP calls. /// /// The API client. public ApiClient ApiClient; - private readonly Dictionary _defaultHeaderMap = new Dictionary(); + private Dictionary _defaultHeaderMap = new Dictionary(); /// - /// Gets the default header. + /// Gets or sets the default header. /// public Dictionary DefaultHeader { get { return _defaultHeaderMap; } + + set + { + _defaultHeaderMap = value; + } } /// 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 03551f9492..d9cb6b2100 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 1d214430ec..2191707bd0 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 ab60577e85..10c44fb46a 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 cf77c2470b..93210505bf 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 eca977c3b1..1fbd17da99 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/TestConfiguration.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs index a72e1a5ed1..140fd26983 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs @@ -107,5 +107,17 @@ namespace SwaggerClientTest.TestConfiguration Assert.AreSame (p4.Configuration.ApiClient, a1); } + [Test ()] + public void TestTimeout () + { + Configuration c1 = new Configuration(); + Assert.AreEqual(100000, c1.Timeout); // default vaue + + c1.Timeout = 50000; + Assert.AreEqual(50000, c1.Timeout); + + Configuration c2 = new Configuration(timeout: 20000); + Assert.AreEqual(20000, c2.Timeout); + } } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs index 7c21f8efea..fbbf449495 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs @@ -114,7 +114,10 @@ namespace SwaggerClientTest.TestPet [Test ()] public void TestGetPetById () { - PetApi petApi = new PetApi (); + // set timeout to 10 seconds + Configuration c1 = new Configuration (timeout: 10000); + + PetApi petApi = new PetApi (c1); Pet response = petApi.GetPetById (petId); Assert.IsInstanceOf (response, "Response is a Pet"); diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll index 1cc6bc94f0..b0a59cff94 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 ce46e4ce0a..25bc7b803d 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 7d68ff048e..f115c595d6 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,9 +1,9 @@ /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 /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb +/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 1cc6bc94f0..b0a59cff94 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 ce46e4ce0a..25bc7b803d 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