forked from loafle/openapi-generator-original
Merge branch 'master-fix#19176' of https://github.com/filipe-silva/openapi-generator into filipe-silva-master-fix#19176
This commit is contained in:
commit
9ade653596
@ -449,10 +449,9 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -485,7 +484,7 @@ namespace {{packageName}}.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -581,21 +580,21 @@ namespace {{packageName}}.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#supportsAsync}}
|
{{#supportsAsync}}
|
||||||
@ -606,9 +605,7 @@ namespace {{packageName}}.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
{{#supportsRetry}}
|
{{#supportsRetry}}
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
@ -625,10 +622,8 @@ namespace {{packageName}}.Client
|
|||||||
}
|
}
|
||||||
{{/supportsRetry}}
|
{{/supportsRetry}}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
@ -449,10 +449,9 @@ namespace Org.OpenAPITools.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -469,7 +468,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -565,21 +564,21 @@ namespace Org.OpenAPITools.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
@ -589,9 +588,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
{
|
{
|
||||||
@ -604,10 +601,8 @@ namespace Org.OpenAPITools.Client
|
|||||||
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
@ -449,10 +449,9 @@ namespace Org.OpenAPITools.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -469,7 +468,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -565,21 +564,21 @@ namespace Org.OpenAPITools.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
@ -589,9 +588,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
{
|
{
|
||||||
@ -604,10 +601,8 @@ namespace Org.OpenAPITools.Client
|
|||||||
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
@ -450,10 +450,9 @@ namespace Org.OpenAPITools.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -484,7 +483,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -580,21 +579,21 @@ namespace Org.OpenAPITools.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
@ -604,9 +603,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
{
|
{
|
||||||
@ -619,10 +616,8 @@ namespace Org.OpenAPITools.Client
|
|||||||
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
@ -450,10 +450,9 @@ namespace Org.OpenAPITools.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -484,7 +483,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -580,21 +579,21 @@ namespace Org.OpenAPITools.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
@ -604,9 +603,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
{
|
{
|
||||||
@ -619,10 +616,8 @@ namespace Org.OpenAPITools.Client
|
|||||||
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
@ -450,10 +450,9 @@ namespace Org.OpenAPITools.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -484,7 +483,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -580,21 +579,21 @@ namespace Org.OpenAPITools.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
@ -604,9 +603,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
{
|
{
|
||||||
@ -619,10 +616,8 @@ namespace Org.OpenAPITools.Client
|
|||||||
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
@ -448,10 +448,9 @@ namespace Org.OpenAPITools.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -468,7 +467,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -564,21 +563,21 @@ namespace Org.OpenAPITools.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
@ -588,9 +587,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
{
|
{
|
||||||
@ -603,10 +600,8 @@ namespace Org.OpenAPITools.Client
|
|||||||
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
@ -449,10 +449,9 @@ namespace Org.OpenAPITools.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -483,7 +482,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -579,21 +578,21 @@ namespace Org.OpenAPITools.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
@ -603,9 +602,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
{
|
{
|
||||||
@ -618,10 +615,8 @@ namespace Org.OpenAPITools.Client
|
|||||||
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
@ -449,10 +449,9 @@ namespace Org.OpenAPITools.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -483,7 +482,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -579,21 +578,21 @@ namespace Org.OpenAPITools.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
@ -603,9 +602,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
{
|
{
|
||||||
@ -618,10 +615,8 @@ namespace Org.OpenAPITools.Client
|
|||||||
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
@ -448,10 +448,9 @@ namespace Org.OpenAPITools.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -468,7 +467,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -564,21 +563,21 @@ namespace Org.OpenAPITools.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
@ -588,9 +587,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
{
|
{
|
||||||
@ -603,10 +600,8 @@ namespace Org.OpenAPITools.Client
|
|||||||
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
@ -450,10 +450,9 @@ namespace Org.OpenAPITools.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -484,7 +483,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -580,21 +579,21 @@ namespace Org.OpenAPITools.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
@ -604,9 +603,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
{
|
{
|
||||||
@ -619,10 +616,8 @@ namespace Org.OpenAPITools.Client
|
|||||||
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
@ -450,10 +450,9 @@ namespace Org.OpenAPITools.Client
|
|||||||
/// <param name="configuration">A per-request configuration object.
|
/// <param name="configuration">A per-request configuration object.
|
||||||
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
/// It is assumed that any merge with GlobalConfiguration has been done before calling this method.</param>
|
||||||
/// <returns>A new ApiResponse instance.</returns>
|
/// <returns>A new ApiResponse instance.</returns>
|
||||||
private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<RestResponse<T>>> getResponse, Action<RestClientOptions> setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
|
||||||
|
|
||||||
var clientOptions = new RestClientOptions(baseUrl)
|
var clientOptions = new RestClientOptions(baseUrl)
|
||||||
{
|
{
|
||||||
ClientCertificates = configuration.ClientCertificates,
|
ClientCertificates = configuration.ClientCertificates,
|
||||||
@ -484,7 +483,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
{
|
{
|
||||||
InterceptRequest(request);
|
InterceptRequest(request);
|
||||||
|
|
||||||
RestResponse<T> response = getResponse(client);
|
RestResponse<T> response = await getResponse(client);
|
||||||
|
|
||||||
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
|
||||||
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
|
||||||
@ -580,21 +579,21 @@ namespace Org.OpenAPITools.Client
|
|||||||
clientOptions.CookieContainer = cookies;
|
clientOptions.CookieContainer = cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = (client) =>
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.RetryPolicy != null)
|
if (RetryConfiguration.RetryPolicy != null)
|
||||||
{
|
{
|
||||||
var policy = RetryConfiguration.RetryPolicy;
|
var policy = RetryConfiguration.RetryPolicy;
|
||||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return client.Execute<T>(request);
|
return Task.FromResult(client.Execute<T>(request));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return ExecClient(getResponse, setOptions, request, options, configuration);
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
private Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
@ -604,9 +603,7 @@ namespace Org.OpenAPITools.Client
|
|||||||
//no extra options
|
//no extra options
|
||||||
};
|
};
|
||||||
|
|
||||||
Func<RestClient, RestResponse<T>> getResponse = (client) =>
|
Func<RestClient, Task<RestResponse<T>>> getResponse = async (client) =>
|
||||||
{
|
|
||||||
Func<Task<RestResponse<T>>> action = async () =>
|
|
||||||
{
|
{
|
||||||
if (RetryConfiguration.AsyncRetryPolicy != null)
|
if (RetryConfiguration.AsyncRetryPolicy != null)
|
||||||
{
|
{
|
||||||
@ -619,10 +616,8 @@ namespace Org.OpenAPITools.Client
|
|||||||
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
return await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return action().Result;
|
|
||||||
};
|
|
||||||
|
|
||||||
return Task.FromResult<ApiResponse<T>>(ExecClient(getResponse, setOptions, request, options, configuration));
|
return ExecClientAsync(getResponse, setOptions, request, options, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IAsynchronousClient
|
#region IAsynchronousClient
|
||||||
|
Loading…
x
Reference in New Issue
Block a user