mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 06:30:52 +00:00
csharp add timeout, fix default constructor
This commit is contained in:
parent
968c943c44
commit
0aa4d2fb8e
@ -24,15 +24,16 @@ namespace {{packageName}}.Client
|
||||
/// <param name="apiKeyPrefix">Dictionary of API key prefix</param>
|
||||
/// <param name="tempFolderPath">Temp folder path</param>
|
||||
/// <param name="dateTimeFormat">DateTime format string</param>
|
||||
public Configuration(ApiClient apiClient,
|
||||
Dictionary<String, String> defaultHeader,
|
||||
string username,
|
||||
string password,
|
||||
string accessToken,
|
||||
Dictionary<String, String> apiKey,
|
||||
Dictionary<String, String> apiKeyPrefix,
|
||||
string tempFolderPath,
|
||||
string dateTimeFormat
|
||||
public Configuration(ApiClient apiClient = null,
|
||||
Dictionary<String, String> defaultHeader = null,
|
||||
string username = null,
|
||||
string password = null,
|
||||
string accessToken = null,
|
||||
Dictionary<String, String> apiKey = null,
|
||||
Dictionary<String, String> apiKeyPrefix = null,
|
||||
string tempFolderPath = null,
|
||||
string dateTimeFormat = null,
|
||||
int timeout = 100
|
||||
)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the Configuration class.
|
||||
/// </summary>
|
||||
/// <param name="apiClient">Api client.</param>
|
||||
public Configuration(ApiClient apiClient=null)
|
||||
public Configuration(ApiClient apiClient)
|
||||
{
|
||||
if (apiClient == null)
|
||||
ApiClient = ApiClient.Default;
|
||||
@ -75,20 +81,39 @@ namespace {{packageName}}.Client
|
||||
/// <value>Configuration.</value>
|
||||
public static Configuration Default = new Configuration();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the timeout value of ApiClient. Default to 100 seconds.
|
||||
/// </summary>
|
||||
/// <value>Timeout.</value>
|
||||
public int Timeout
|
||||
{
|
||||
get { return ApiClient.RestClient.Timeout; }
|
||||
|
||||
set
|
||||
{
|
||||
ApiClient.RestClient.Timeout = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
public ApiClient ApiClient;
|
||||
|
||||
private readonly Dictionary<String, String> _defaultHeaderMap = new Dictionary<String, String>();
|
||||
private Dictionary<String, String> _defaultHeaderMap = new Dictionary<String, String>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default header.
|
||||
/// Gets or sets the default header.
|
||||
/// </summary>
|
||||
public Dictionary<String, String> DefaultHeader
|
||||
{
|
||||
get { return _defaultHeaderMap; }
|
||||
|
||||
set
|
||||
{
|
||||
_defaultHeaderMap = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -6,7 +6,6 @@ using RestSharp;
|
||||
using IO.Swagger.Client;
|
||||
using IO.Swagger.Model;
|
||||
|
||||
|
||||
namespace IO.Swagger.Api
|
||||
{
|
||||
|
||||
|
@ -6,7 +6,6 @@ using RestSharp;
|
||||
using IO.Swagger.Client;
|
||||
using IO.Swagger.Model;
|
||||
|
||||
|
||||
namespace IO.Swagger.Api
|
||||
{
|
||||
|
||||
|
@ -6,7 +6,6 @@ using RestSharp;
|
||||
using IO.Swagger.Client;
|
||||
using IO.Swagger.Model;
|
||||
|
||||
|
||||
namespace IO.Swagger.Api
|
||||
{
|
||||
|
||||
|
@ -24,15 +24,16 @@ namespace IO.Swagger.Client
|
||||
/// <param name="apiKeyPrefix">Dictionary of API key prefix</param>
|
||||
/// <param name="tempFolderPath">Temp folder path</param>
|
||||
/// <param name="dateTimeFormat">DateTime format string</param>
|
||||
public Configuration(ApiClient apiClient,
|
||||
Dictionary<String, String> defaultHeader,
|
||||
string username,
|
||||
string password,
|
||||
string accessToken,
|
||||
Dictionary<String, String> apiKey,
|
||||
Dictionary<String, String> apiKeyPrefix,
|
||||
string tempFolderPath,
|
||||
string dateTimeFormat
|
||||
public Configuration(ApiClient apiClient = null,
|
||||
Dictionary<String, String> defaultHeader = null,
|
||||
string username = null,
|
||||
string password = null,
|
||||
string accessToken = null,
|
||||
Dictionary<String, String> apiKey = null,
|
||||
Dictionary<String, String> apiKeyPrefix = null,
|
||||
string tempFolderPath = null,
|
||||
string dateTimeFormat = null,
|
||||
int timeout = 100
|
||||
)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the Configuration class.
|
||||
/// </summary>
|
||||
/// <param name="apiClient">Api client.</param>
|
||||
public Configuration(ApiClient apiClient=null)
|
||||
public Configuration(ApiClient apiClient)
|
||||
{
|
||||
if (apiClient == null)
|
||||
ApiClient = ApiClient.Default;
|
||||
@ -75,20 +81,39 @@ namespace IO.Swagger.Client
|
||||
/// <value>Configuration.</value>
|
||||
public static Configuration Default = new Configuration();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the timeout value of ApiClient. Default to 100 seconds.
|
||||
/// </summary>
|
||||
/// <value>Timeout.</value>
|
||||
public int Timeout
|
||||
{
|
||||
get { return ApiClient.RestClient.Timeout; }
|
||||
|
||||
set
|
||||
{
|
||||
ApiClient.RestClient.Timeout = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
public ApiClient ApiClient;
|
||||
|
||||
private readonly Dictionary<String, String> _defaultHeaderMap = new Dictionary<String, String>();
|
||||
private Dictionary<String, String> _defaultHeaderMap = new Dictionary<String, String>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default header.
|
||||
/// Gets or sets the default header.
|
||||
/// </summary>
|
||||
public Dictionary<String, String> DefaultHeader
|
||||
{
|
||||
get { return _defaultHeaderMap; }
|
||||
|
||||
set
|
||||
{
|
||||
_defaultHeaderMap = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -107,5 +107,20 @@ namespace SwaggerClientTest.TestConfiguration
|
||||
Assert.AreSame (p4.Configuration.ApiClient, a1);
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestTimeout ()
|
||||
{
|
||||
Configuration c1 = new Configuration();
|
||||
Assert.AreEqual(c1.Timeout, 100); // default vaue
|
||||
|
||||
c1.Timeout = 10;
|
||||
Assert.AreEqual(c1.Timeout, 10);
|
||||
|
||||
Configuration c2 = new Configuration(timeout: 20);
|
||||
Assert.AreEqual(c2.Timeout, 20);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -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
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user