mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-12 15:54:17 +00:00
update csharp configuration to avoid circular dependency, deprecate
ApiClient.Default
This commit is contained in:
@@ -61,7 +61,8 @@ namespace {{packageName}}.Client
|
||||
/// Gets or sets the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
/// <value>The default API client.</value>
|
||||
public static ApiClient Default = new ApiClient(Configuration.Default);
|
||||
[Obsolete("ApiClient.Default is deprecated, please use 'Configuraiton.Default.ApiClient' instead.")]
|
||||
public static ApiClient Default;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Configuration.
|
||||
|
||||
@@ -37,10 +37,7 @@ namespace {{packageName}}.Client
|
||||
int timeout = 100000
|
||||
)
|
||||
{
|
||||
if (apiClient == null)
|
||||
ApiClient = ApiClient.Default == null ? new ApiClient() : ApiClient.Default;
|
||||
else
|
||||
ApiClient = apiClient;
|
||||
setApiClientUsingDefault(apiClient);
|
||||
|
||||
Username = username;
|
||||
Password = password;
|
||||
@@ -64,18 +61,15 @@ namespace {{packageName}}.Client
|
||||
/// <param name="apiClient">Api client.</param>
|
||||
public Configuration(ApiClient apiClient)
|
||||
{
|
||||
if (apiClient == null)
|
||||
ApiClient = ApiClient.Default;
|
||||
else
|
||||
ApiClient = apiClient;
|
||||
setApiClientUsingDefault(apiClient);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Version of the package.
|
||||
/// </summary>
|
||||
/// <value>Version of the package.</value>
|
||||
public const string Version = "{{packageVersion}}";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default Configuration.
|
||||
/// </summary>
|
||||
@@ -103,8 +97,31 @@ namespace {{packageName}}.Client
|
||||
/// <value>The API client.</value>
|
||||
public ApiClient ApiClient;
|
||||
|
||||
/// <summary>
|
||||
/// Set the ApiClient using Default or ApiClient instance
|
||||
/// </summary>
|
||||
/// <param name="apiClient">An instance of ApiClient
|
||||
/// <returns></returns>
|
||||
public void setApiClientUsingDefault (ApiClient apiClient = null)
|
||||
{
|
||||
if (apiClient == null)
|
||||
{
|
||||
if (Default != null && Default.ApiClient == null)
|
||||
Default.ApiClient = new ApiClient();
|
||||
|
||||
ApiClient = Default != null ? Default.ApiClient : new ApiClient();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Default != null && Default.ApiClient == null)
|
||||
Default.ApiClient = apiClient;
|
||||
|
||||
ApiClient = apiClient;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<String, String> _defaultHeaderMap = new Dictionary<String, String>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default header.
|
||||
/// </summary>
|
||||
@@ -134,13 +151,13 @@ namespace {{packageName}}.Client
|
||||
/// </summary>
|
||||
/// <value>The username.</value>
|
||||
public String Username { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the password (HTTP basic authentication).
|
||||
/// </summary>
|
||||
/// <value>The password.</value>
|
||||
public String Password { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the access token for OAuth2 authentication.
|
||||
/// </summary>
|
||||
@@ -152,7 +169,7 @@ namespace {{packageName}}.Client
|
||||
/// </summary>
|
||||
/// <value>The API key.</value>
|
||||
public Dictionary<String, String> ApiKey = new Dictionary<String, String>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
|
||||
/// </summary>
|
||||
@@ -174,9 +191,9 @@ namespace {{packageName}}.Client
|
||||
else
|
||||
return apiKeyValue;
|
||||
}
|
||||
|
||||
|
||||
private string _tempFolderPath = Path.GetTempPath();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the temporary folder path to store the files downloaded from the server.
|
||||
/// </summary>
|
||||
@@ -184,19 +201,19 @@ namespace {{packageName}}.Client
|
||||
public String TempFolderPath
|
||||
{
|
||||
get { return _tempFolderPath; }
|
||||
|
||||
set
|
||||
|
||||
set
|
||||
{
|
||||
if (String.IsNullOrEmpty(value))
|
||||
{
|
||||
_tempFolderPath = value;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// create the directory if it does not exist
|
||||
if (!Directory.Exists(value))
|
||||
Directory.CreateDirectory(value);
|
||||
|
||||
|
||||
// check if the path contains directory separator at the end
|
||||
if (value[value.Length - 1] == Path.DirectorySeparatorChar)
|
||||
_tempFolderPath = value;
|
||||
@@ -251,7 +268,7 @@ namespace {{packageName}}.Client
|
||||
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
|
||||
report += " Version of the API: {{version}}\n";
|
||||
report += " SDK Package Version: {{packageVersion}}\n";
|
||||
|
||||
|
||||
return report;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user