Skip to content

Commit

Permalink
feat: Initial support of partial methods for methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 8, 2024
1 parent 1764d8e commit 0d884c3
Show file tree
Hide file tree
Showing 1,351 changed files with 24,937 additions and 3 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.12.2</Version>
<Version>0.13.0</Version>
<MinVerMinimumMajorMinor>0.1</MinVerMinimumMajorMinor>
<MinVerTagPrefix>v</MinVerTagPrefix>
<MinVerDefaultPreReleaseIdentifiers>dev</MinVerDefaultPreReleaseIdentifiers>
Expand Down
5 changes: 3 additions & 2 deletions src/libs/OpenApiGenerator.Core/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ public static class StringExtensions
/// Returns " " if collection is empty(to use with <see cref="RemoveBlankLinesWhereOnlyWhitespaces(string)"/>).
/// </summary>
/// <param name="values"></param>
/// <param name="emptyValue"></param>
/// <returns></returns>
public static string Inject(this IEnumerable<string> values)
public static string Inject(this IEnumerable<string> values, string emptyValue = " ")
{
var text = string.Concat(values)
.TrimStart('\r', '\n')
.TrimEnd('\r', '\n');
if (string.IsNullOrWhiteSpace(text))
{
return " ";
return emptyValue;
}

return text;
Expand Down
16 changes: 16 additions & 0 deletions src/libs/OpenApiGenerator.Core/Generation/Sources.Clients.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ public void Dispose()
{{
_httpClient.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,
ref string content);
}}
}}".RemoveBlankLinesWhereOnlyWhitespaces();
}
Expand Down
26 changes: 26 additions & 0 deletions src/libs/OpenApiGenerator.Core/Generation/Sources.Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,32 @@ namespace {endPoint.Namespace}
{{
public partial class {endPoint.ClassName}
{{
partial void Prepare{endPoint.NotAsyncMethodName}Arguments(
global::System.Net.Http.HttpClient httpClient{endPoint.Properties
.Where(x => x.ParameterLocation != null)
.Select(x => $@",
{(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
.Where(x => x.ParameterLocation != null)
.Select(x => $@",
{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);
partial void Process{endPoint.NotAsyncMethodName}ResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);
{GenerateMethod(endPoint)}
{GenerateExtensionMethod(endPoint)}
}}
Expand Down
5 changes: 5 additions & 0 deletions src/libs/OpenApiGenerator.Core/Models/TypeData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public readonly record struct TypeData(
public string ShortCSharpTypeWithoutNullability => CSharpTypeWithoutNullability.Replace($"global::{Namespace}.", string.Empty);
public string ShortCSharpTypeWithNullability => ShortCSharpTypeWithoutNullability + "?";
public bool IsAnyOf => AnyOfCount > 0 || OneOfCount > 0 || AllOfCount > 0;

public bool IsReferenceable =>
CSharpTypeWithoutNullability is "string" or "int" or "long" or "float" or "double" or "bool" ||
IsAnyOf ||
IsEnum;

public string ConverterType => IsEnum
? $"global::OpenApiGenerator.JsonConverters.{ShortCSharpTypeWithoutNullability}JsonConverter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountDisableRecurringPaymentArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token,
ref string accountId);
partial void PrepareAccountDisableRecurringPaymentRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token,
string accountId);
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,
ref string content);

/// <summary>
/// DisableRecurringPayment.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountGetAccountBillingLogsForCurrentUserArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token);
partial void PrepareAccountGetAccountBillingLogsForCurrentUserRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token);
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,
ref string content);

/// <summary>
/// GetAccountBillingLogsForCurrentUser.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountGetAccountDetailsForCurrentUserArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token);
partial void PrepareAccountGetAccountDetailsForCurrentUserRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token);
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,
ref string content);

/// <summary>
/// GetAccountDetailsForCurrentUser.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountGetAccountForCurrentUserArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token);
partial void PrepareAccountGetAccountForCurrentUserRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token);
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,
ref string content);

/// <summary>
/// GetAccountForCurrentUser.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountGetAccountProjectInfoJobResponseArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token,
ref string jobId);
partial void PrepareAccountGetAccountProjectInfoJobResponseRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token,
string jobId);
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,
ref string content);

/// <summary>
/// GetAccountProjectInfoJobResponse.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountGetExportStorageMetricsJobIdArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token,
ref string accountId);
partial void PrepareAccountGetExportStorageMetricsJobIdRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token,
string accountId);
partial void ProcessAccountGetExportStorageMetricsJobIdResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
partial void ProcessAccountGetExportStorageMetricsJobIdResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// GetExportStorageMetricsJobId.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountGetProjectAccessDetailsForUserArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token,
ref string userId);
partial void PrepareAccountGetProjectAccessDetailsForUserRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token,
string userId);
partial void ProcessAccountGetProjectAccessDetailsForUserResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
partial void ProcessAccountGetProjectAccessDetailsForUserResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// GetProjectAccessDetailsForUser.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountGetProjectAccessDetailsForUser2Arguments(
global::System.Net.Http.HttpClient httpClient,
ref string token,
ref string userId);
partial void PrepareAccountGetProjectAccessDetailsForUser2Request(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token,
string userId);
partial void ProcessAccountGetProjectAccessDetailsForUser2Response(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
partial void ProcessAccountGetProjectAccessDetailsForUser2ResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// GetProjectAccessDetailsForUser.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountGrantAdminArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token,
ref string accountId,
ref string userId);
partial void PrepareAccountGrantAdminRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token,
string accountId,
string userId);
partial void ProcessAccountGrantAdminResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
partial void ProcessAccountGrantAdminResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// GrantAdmin.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountRemoveUserFromCurrentAccountArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token,
ref string userId);
partial void PrepareAccountRemoveUserFromCurrentAccountRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token,
string userId);
partial void ProcessAccountRemoveUserFromCurrentAccountResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
partial void ProcessAccountRemoveUserFromCurrentAccountResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// RemoveUserFromCurrentAccount.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountRevokeAdminArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token,
ref string accountId,
ref string userId);
partial void PrepareAccountRevokeAdminRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token,
string accountId,
string userId);
partial void ProcessAccountRevokeAdminResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
partial void ProcessAccountRevokeAdminResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// RevokeAdmin.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ namespace G
{
public partial class AccountClient
{
partial void PrepareAccountSendPaymentReceiptArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token,
ref string accountId,
ref string transactionId,
ref string email);
partial void PrepareAccountSendPaymentReceiptRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token,
string accountId,
string transactionId,
string email);
partial void ProcessAccountSendPaymentReceiptResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
partial void ProcessAccountSendPaymentReceiptResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// SendPaymentReceipt.
/// </summary>
Expand Down
Loading

0 comments on commit 0d884c3

Please sign in to comment.