Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[csharp-netcore][generichost] Added OrDefault method #15551

Merged
merged 1 commit into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,21 @@ namespace {{packageName}}.{{interfacePrefix}}{{apiPackage}}
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task&lt;ApiResponse&lt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}object{{/returnType}}{{nrt?}}&gt;&gt;</returns>
/// <returns>Task&lt;ApiResponse&lt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}object{{/returnType}}&gt;&gt;</returns>
Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}>> {{operationId}}Async({{>OperationSignature}});

/// <summary>
/// {{summary}}
/// </summary>
/// <remarks>
/// {{notes}}
/// </remarks>
{{#allParams}}
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task&lt;ApiResponse&gt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}object{{/returnType}}&gt;{{nrt?}}&gt;</returns>
Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}>{{nrt?}}> {{operationId}}OrDefaultAsync({{>OperationSignature}});
{{^-last}}

{{/-last}}
Expand Down Expand Up @@ -183,6 +196,26 @@ namespace {{packageName}}.{{apiPackage}}
Logger.LogError(exception, "An error occurred while sending the request to the server.");
}

/// <summary>
/// {{summary}} {{notes}}
/// </summary>
{{#allParams}}
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="ApiResponse{T}"/>&gt; where T : <see cref="{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}object{{/returnType}}"/></returns>
public async Task<ApiResponse<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}object{{/returnType}}>{{nrt?}}> {{operationId}}OrDefaultAsync({{>OperationSignature}})
{
try
{
return await {{operationId}}Async({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}

/// <summary>
/// {{summary}} {{notes}}
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@ public interface IAnotherFakeApi : IApi
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="modelClient">client model</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task&lt;ApiResponse&lt;ModelClient?&gt;&gt;</returns>
/// <returns>Task&lt;ApiResponse&lt;ModelClient&gt;&gt;</returns>
Task<ApiResponse<ModelClient>> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null);

/// <summary>
/// To test special tags
/// </summary>
/// <remarks>
/// To test special tags and operation ID starting with number
/// </remarks>
/// <param name="modelClient">client model</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task&lt;ApiResponse&gt;ModelClient&gt;?&gt;</returns>
Task<ApiResponse<ModelClient>?> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null);
}
}

Expand Down Expand Up @@ -157,6 +168,24 @@ protected virtual void OnErrorCall123TestSpecialTags(Exception exception, string
Logger.LogError(exception, "An error occurred while sending the request to the server.");
}

/// <summary>
/// To test special tags To test special tags and operation ID starting with number
/// </summary>
/// <param name="modelClient">client model</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="ApiResponse{T}"/>&gt; where T : <see cref="ModelClient"/></returns>
public async Task<ApiResponse<ModelClient>?> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken? cancellationToken = null)
{
try
{
return await Call123TestSpecialTagsAsync(modelClient, cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}

/// <summary>
/// To test special tags To test special tags and operation ID starting with number
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,19 @@ public interface IDefaultApi : IApi
/// </remarks>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task&lt;ApiResponse&lt;FooGetDefaultResponse?&gt;&gt;</returns>
/// <returns>Task&lt;ApiResponse&lt;FooGetDefaultResponse&gt;&gt;</returns>
Task<ApiResponse<FooGetDefaultResponse>> FooGetAsync(System.Threading.CancellationToken? cancellationToken = null);

/// <summary>
///
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task&lt;ApiResponse&gt;FooGetDefaultResponse&gt;?&gt;</returns>
Task<ApiResponse<FooGetDefaultResponse>?> FooGetOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null);

/// <summary>
///
/// </summary>
Expand All @@ -49,9 +59,20 @@ public interface IDefaultApi : IApi
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="country"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task&lt;ApiResponse&lt;object?&gt;&gt;</returns>
/// <returns>Task&lt;ApiResponse&lt;object&gt;&gt;</returns>
Task<ApiResponse<object>> GetCountryAsync(string country, System.Threading.CancellationToken? cancellationToken = null);

/// <summary>
///
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="country"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task&lt;ApiResponse&gt;object&gt;?&gt;</returns>
Task<ApiResponse<object>?> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken? cancellationToken = null);

/// <summary>
/// Hello
/// </summary>
Expand All @@ -60,8 +81,18 @@ public interface IDefaultApi : IApi
/// </remarks>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task&lt;ApiResponse&lt;List&lt;Guid&gt;?&gt;&gt;</returns>
/// <returns>Task&lt;ApiResponse&lt;List&lt;Guid&gt;&gt;&gt;</returns>
Task<ApiResponse<List<Guid>>> HelloAsync(System.Threading.CancellationToken? cancellationToken = null);

/// <summary>
/// Hello
/// </summary>
/// <remarks>
/// Hello
/// </remarks>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task&lt;ApiResponse&gt;List&lt;Guid&gt;&gt;?&gt;</returns>
Task<ApiResponse<List<Guid>>?> HelloOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null);
}
}

Expand Down Expand Up @@ -167,6 +198,23 @@ protected virtual void OnErrorFooGet(Exception exception, string pathFormat, str
Logger.LogError(exception, "An error occurred while sending the request to the server.");
}

/// <summary>
///
/// </summary>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="ApiResponse{T}"/>&gt; where T : <see cref="FooGetDefaultResponse"/></returns>
public async Task<ApiResponse<FooGetDefaultResponse>?> FooGetOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null)
{
try
{
return await FooGetAsync(cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -266,6 +314,24 @@ protected virtual void OnErrorGetCountry(Exception exception, string pathFormat,
Logger.LogError(exception, "An error occurred while sending the request to the server.");
}

/// <summary>
///
/// </summary>
/// <param name="country"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="ApiResponse{T}"/>&gt; where T : <see cref="object"/></returns>
public async Task<ApiResponse<object>?> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken? cancellationToken = null)
{
try
{
return await GetCountryAsync(country, cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -364,6 +430,23 @@ protected virtual void OnErrorHello(Exception exception, string pathFormat, stri
Logger.LogError(exception, "An error occurred while sending the request to the server.");
}

/// <summary>
/// Hello Hello
/// </summary>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="ApiResponse{T}"/>&gt; where T : <see cref="List&lt;Guid&gt;"/></returns>
public async Task<ApiResponse<List<Guid>>?> HelloOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null)
{
try
{
return await HelloAsync(cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}

/// <summary>
/// Hello Hello
/// </summary>
Expand Down
Loading
Loading