Skip to content

Commit

Permalink
feat: Implemented partial methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 8, 2024
1 parent f0a393d commit e7189fe
Show file tree
Hide file tree
Showing 1,181 changed files with 40,311 additions and 520 deletions.
2 changes: 1 addition & 1 deletion src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</ItemGroup>

<PropertyGroup Label="Versioning">
<Version>0.13.0</Version>
<Version>0.13.1</Version>
<MinVerMinimumMajorMinor>0.1</MinVerMinimumMajorMinor>
<MinVerTagPrefix>v</MinVerTagPrefix>
<MinVerDefaultPreReleaseIdentifiers>dev</MinVerDefaultPreReleaseIdentifiers>
Expand Down
3 changes: 0 additions & 3 deletions src/libs/OpenApiGenerator.Core/Generation/Sources.Clients.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,12 @@ public void Dispose()
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
global::System.Net.Http.HttpClient client,
global::System.Net.Http.HttpRequestMessage request);
partial void ProcessResponse(
global::System.Net.Http.HttpClient client,
global::System.Net.Http.HttpResponseMessage response);
partial void ProcessResponseContent(
global::System.Net.Http.HttpClient client,
global::System.Net.Http.HttpResponseMessage response,
Expand Down
44 changes: 40 additions & 4 deletions src/libs/OpenApiGenerator.Core/Generation/Sources.Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public partial class {endPoint.ClassName}
{(x.Type.IsReferenceable ? "ref " : "")}{x.Type.CSharpType} {x.ParameterName}").Inject(emptyValue: "")}{
(string.IsNullOrWhiteSpace(endPoint.RequestType.CSharpType) ? "" : @$",
{endPoint.RequestType.CSharpTypeWithoutNullability} request")});
partial void Prepare{endPoint.NotAsyncMethodName}Request(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage{endPoint.Properties
Expand All @@ -43,15 +42,14 @@ public partial class {endPoint.ClassName}
{x.Type.CSharpType} {x.ParameterName}").Inject(emptyValue: "")}{
(string.IsNullOrWhiteSpace(endPoint.RequestType.CSharpType) ? "" : @$",
{endPoint.RequestType.CSharpTypeWithoutNullability} request")});
partial void Process{endPoint.NotAsyncMethodName}Response(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
{(string.IsNullOrWhiteSpace(endPoint.ResponseType.CSharpType) || endPoint.Stream ? " " : $@"
partial void Process{endPoint.NotAsyncMethodName}ResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);
ref string content);")}
{GenerateMethod(endPoint)}
{GenerateExtensionMethod(endPoint)}
Expand Down Expand Up @@ -113,6 +111,16 @@ public static string GenerateMethod(
{(string.IsNullOrWhiteSpace(endPoint.RequestType.CSharpType) ? " " : @"
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
")}
PrepareArguments(
client: _httpClient);
Prepare{endPoint.NotAsyncMethodName}Arguments(
httpClient: _httpClient{endPoint.Properties
.Where(x => x.ParameterLocation != null)
.Select(x => $@",
{x.ParameterName}: {(x.Type.IsReferenceable ? "ref " : "")}{x.ParameterName}").Inject(emptyValue: "")}{
(string.IsNullOrWhiteSpace(endPoint.RequestType.CSharpType) ? "" : @",
request: request")});
{(endPoint.Settings.JsonSerializerType == JsonSerializerType.NewtonsoftJson ? endPoint.Properties
.Where(x => x is { ParameterLocation: not null, Type.EnumValues.Length: > 0 })
.Select(x => $@"
Expand All @@ -139,15 +147,43 @@ public static string GenerateMethod(
encoding: global::System.Text.Encoding.UTF8,
mediaType: ""application/octet-stream"");")}
PrepareRequest(
client: _httpClient,
request: httpRequest);
Prepare{endPoint.NotAsyncMethodName}Request(
httpClient: _httpClient,
httpRequestMessage: httpRequest{endPoint.Properties
.Where(x => x.ParameterLocation != null)
.Select(x => $@",
{x.ParameterName}: {x.ParameterName}").Inject(emptyValue: "")}{
(string.IsNullOrWhiteSpace(endPoint.RequestType.CSharpType) ? "" : @",
request: request")});
using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.{httpCompletionOption},
cancellationToken: cancellationToken).ConfigureAwait(false);
ProcessResponse(
client: _httpClient,
response: response);
Process{endPoint.NotAsyncMethodName}Response(
httpClient: _httpClient,
httpResponseMessage: response);
{(string.IsNullOrWhiteSpace(endPoint.ResponseType.CSharpType) || endPoint.Stream ? @"
response.EnsureSuccessStatusCode();
" : $@"
var __content = await response.Content.ReadAsStringAsync({cancellationTokenInsideReadAsync}).ConfigureAwait(false);
ProcessResponseContent(
client: _httpClient,
response: response,
content: ref __content);
Process{endPoint.NotAsyncMethodName}ResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);
try
{{
response.EnsureSuccessStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ partial void PrepareAccountDisableRecurringPaymentRequest(
partial void ProcessAccountDisableRecurringPaymentResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessAccountDisableRecurringPaymentResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
Expand All @@ -35,17 +36,49 @@ partial void ProcessAccountDisableRecurringPaymentResponseContent(
string accountId,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareAccountDisableRecurringPaymentArguments(
httpClient: _httpClient,
token: ref token,
accountId: ref accountId);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Get,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/api/v1/account/disablerecurringpayment?accountId={accountId}", global::System.UriKind.RelativeOrAbsolute));

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareAccountDisableRecurringPaymentRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
token: token,
accountId: accountId);

using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
ProcessAccountDisableRecurringPaymentResponse(
httpClient: _httpClient,
httpResponseMessage: response);

var __content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

ProcessResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessAccountDisableRecurringPaymentResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);

try
{
response.EnsureSuccessStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ partial void PrepareAccountGetAccountBillingLogsForCurrentUserRequest(
partial void ProcessAccountGetAccountBillingLogsForCurrentUserResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessAccountGetAccountBillingLogsForCurrentUserResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
Expand All @@ -31,17 +32,47 @@ partial void ProcessAccountGetAccountBillingLogsForCurrentUserResponseContent(
string token,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareAccountGetAccountBillingLogsForCurrentUserArguments(
httpClient: _httpClient,
token: ref token);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Get,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + "/api/v1/account/getaccountbillinglogsforcurrentuser", global::System.UriKind.RelativeOrAbsolute));

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareAccountGetAccountBillingLogsForCurrentUserRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
token: token);

using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
ProcessAccountGetAccountBillingLogsForCurrentUserResponse(
httpClient: _httpClient,
httpResponseMessage: response);

var __content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

ProcessResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessAccountGetAccountBillingLogsForCurrentUserResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);

try
{
response.EnsureSuccessStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ partial void PrepareAccountGetAccountDetailsForCurrentUserRequest(
partial void ProcessAccountGetAccountDetailsForCurrentUserResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessAccountGetAccountDetailsForCurrentUserResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
Expand All @@ -31,17 +32,47 @@ partial void ProcessAccountGetAccountDetailsForCurrentUserResponseContent(
string token,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareAccountGetAccountDetailsForCurrentUserArguments(
httpClient: _httpClient,
token: ref token);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Get,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + "/api/v1/account/getaccountdetailsforcurrentuser", global::System.UriKind.RelativeOrAbsolute));

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareAccountGetAccountDetailsForCurrentUserRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
token: token);

using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
ProcessAccountGetAccountDetailsForCurrentUserResponse(
httpClient: _httpClient,
httpResponseMessage: response);

var __content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

ProcessResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessAccountGetAccountDetailsForCurrentUserResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);

try
{
response.EnsureSuccessStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ partial void PrepareAccountGetAccountForCurrentUserRequest(
partial void ProcessAccountGetAccountForCurrentUserResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessAccountGetAccountForCurrentUserResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
Expand All @@ -31,17 +32,47 @@ partial void ProcessAccountGetAccountForCurrentUserResponseContent(
string token,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareAccountGetAccountForCurrentUserArguments(
httpClient: _httpClient,
token: ref token);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Get,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + "/api/v1/account/getaccountforcurrentuser", global::System.UriKind.RelativeOrAbsolute));

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareAccountGetAccountForCurrentUserRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
token: token);

using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
ProcessAccountGetAccountForCurrentUserResponse(
httpClient: _httpClient,
httpResponseMessage: response);

var __content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

ProcessResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessAccountGetAccountForCurrentUserResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);

try
{
response.EnsureSuccessStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ partial void PrepareAccountGetAccountProjectInfoJobResponseRequest(
partial void ProcessAccountGetAccountProjectInfoJobResponseResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessAccountGetAccountProjectInfoJobResponseResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
Expand All @@ -35,17 +36,49 @@ partial void ProcessAccountGetAccountProjectInfoJobResponseResponseContent(
string jobId,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareAccountGetAccountProjectInfoJobResponseArguments(
httpClient: _httpClient,
token: ref token,
jobId: ref jobId);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Get,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/api/v1/account/getaccountprojectinfojobresponse?jobId={jobId}", global::System.UriKind.RelativeOrAbsolute));

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareAccountGetAccountProjectInfoJobResponseRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
token: token,
jobId: jobId);

using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
ProcessAccountGetAccountProjectInfoJobResponseResponse(
httpClient: _httpClient,
httpResponseMessage: response);

var __content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

ProcessResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessAccountGetAccountProjectInfoJobResponseResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);

try
{
response.EnsureSuccessStatusCode();
Expand Down
Loading

0 comments on commit e7189fe

Please sign in to comment.