Skip to content

Commit

Permalink
fix: Fixed MethodAndPath OperationId generation for some cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 9, 2024
1 parent 8761fa1 commit 71c6999
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 77 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.2</Version>
<Version>0.13.3</Version>
<MinVerMinimumMajorMinor>0.1</MinVerMinimumMajorMinor>
<MinVerTagPrefix>v</MinVerTagPrefix>
<MinVerDefaultPreReleaseIdentifiers>dev</MinVerDefaultPreReleaseIdentifiers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public string TryGenerate(OpenApiOperation operation, string path, OperationType
_ => throw new NotSupportedException($"OperationType {operationType} is not supported."),
};

path = path.StartsWith("/api", StringComparison.OrdinalIgnoreCase) ? path[4..] : path;
path = path.StartsWith("/v1", StringComparison.OrdinalIgnoreCase) ? path[3..] : path;
path = path.StartsWith("/api", StringComparison.OrdinalIgnoreCase) ? path[4..] : path;

return $"{prefix}{path.TrimStart('/').ToPropertyName().UseWordSeparator('/')}";
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
//HintName: G.LoginClient.CreateApiV1Login.g.cs
//HintName: G.LoginClient.CreateLogin.g.cs

#nullable enable

namespace G
{
public partial class LoginClient
{
partial void PrepareCreateApiV1LoginArguments(
partial void PrepareCreateLoginArguments(
global::System.Net.Http.HttpClient httpClient,
global::G.LoginRequest request);
partial void PrepareCreateApiV1LoginRequest(
partial void PrepareCreateLoginRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
global::G.LoginRequest request);
partial void ProcessCreateApiV1LoginResponse(
partial void ProcessCreateLoginResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessCreateApiV1LoginResponseContent(
partial void ProcessCreateLoginResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);
Expand All @@ -28,15 +28,15 @@ partial void ProcessCreateApiV1LoginResponseContent(
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> CreateApiV1LoginAsync(
public async global::System.Threading.Tasks.Task<string> CreateLoginAsync(
global::G.LoginRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareCreateApiV1LoginArguments(
PrepareCreateLoginArguments(
httpClient: _httpClient,
request: request);

Expand All @@ -52,7 +52,7 @@ partial void ProcessCreateApiV1LoginResponseContent(
PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareCreateApiV1LoginRequest(
PrepareCreateLoginRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
request: request);
Expand All @@ -65,7 +65,7 @@ partial void ProcessCreateApiV1LoginResponseContent(
ProcessResponse(
client: _httpClient,
response: response);
ProcessCreateApiV1LoginResponse(
ProcessCreateLoginResponse(
httpClient: _httpClient,
httpResponseMessage: response);

Expand All @@ -75,7 +75,7 @@ partial void ProcessCreateApiV1LoginResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessCreateApiV1LoginResponseContent(
ProcessCreateLoginResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);
Expand All @@ -101,7 +101,7 @@ partial void ProcessCreateApiV1LoginResponseContent(
/// <param name="rsaEncryptedPassword"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> CreateApiV1LoginAsync(
public async global::System.Threading.Tasks.Task<string> CreateLoginAsync(
string? username = default,
string? rsaEncryptedPassword = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand All @@ -112,7 +112,7 @@ partial void ProcessCreateApiV1LoginResponseContent(
RsaEncryptedPassword = rsaEncryptedPassword,
};

return await CreateApiV1LoginAsync(
return await CreateLoginAsync(
request: request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
//HintName: G.LoginClient.GetApiV1Rsa.g.cs
//HintName: G.LoginClient.GetRsa.g.cs

#nullable enable

namespace G
{
public partial class LoginClient
{
partial void PrepareGetApiV1RsaArguments(
partial void PrepareGetRsaArguments(
global::System.Net.Http.HttpClient httpClient);
partial void PrepareGetApiV1RsaRequest(
partial void PrepareGetRsaRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage);
partial void ProcessGetApiV1RsaResponse(
partial void ProcessGetRsaResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessGetApiV1RsaResponseContent(
partial void ProcessGetRsaResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);
Expand All @@ -25,12 +25,12 @@ partial void ProcessGetApiV1RsaResponseContent(
/// </summary>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::G.RSAWriteKeyInfo> GetApiV1RsaAsync(
public async global::System.Threading.Tasks.Task<global::G.RSAWriteKeyInfo> GetRsaAsync(
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareGetApiV1RsaArguments(
PrepareGetRsaArguments(
httpClient: _httpClient);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
Expand All @@ -40,7 +40,7 @@ partial void ProcessGetApiV1RsaResponseContent(
PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareGetApiV1RsaRequest(
PrepareGetRsaRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest);

Expand All @@ -52,7 +52,7 @@ partial void ProcessGetApiV1RsaResponseContent(
ProcessResponse(
client: _httpClient,
response: response);
ProcessGetApiV1RsaResponse(
ProcessGetRsaResponse(
httpClient: _httpClient,
httpResponseMessage: response);

Expand All @@ -62,7 +62,7 @@ partial void ProcessGetApiV1RsaResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessGetApiV1RsaResponseContent(
ProcessGetRsaResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
//HintName: G.UsersClient.GetApiV1Me.g.cs
//HintName: G.UsersClient.GetMe.g.cs

#nullable enable

namespace G
{
public partial class UsersClient
{
partial void PrepareGetApiV1MeArguments(
partial void PrepareGetMeArguments(
global::System.Net.Http.HttpClient httpClient,
ref string token);
partial void PrepareGetApiV1MeRequest(
partial void PrepareGetMeRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string token);
partial void ProcessGetApiV1MeResponse(
partial void ProcessGetMeResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessGetApiV1MeResponseContent(
partial void ProcessGetMeResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);
Expand All @@ -28,13 +28,13 @@ partial void ProcessGetApiV1MeResponseContent(
/// <param name="token"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::G.ValidateUserResult> GetApiV1MeAsync(
public async global::System.Threading.Tasks.Task<global::G.ValidateUserResult> GetMeAsync(
string token,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareGetApiV1MeArguments(
PrepareGetMeArguments(
httpClient: _httpClient,
token: ref token);

Expand All @@ -45,7 +45,7 @@ partial void ProcessGetApiV1MeResponseContent(
PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareGetApiV1MeRequest(
PrepareGetMeRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
token: token);
Expand All @@ -58,7 +58,7 @@ partial void ProcessGetApiV1MeResponseContent(
ProcessResponse(
client: _httpClient,
response: response);
ProcessGetApiV1MeResponse(
ProcessGetMeResponse(
httpClient: _httpClient,
httpResponseMessage: response);

Expand All @@ -68,7 +68,7 @@ partial void ProcessGetApiV1MeResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessGetApiV1MeResponseContent(
ProcessGetMeResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
//HintName: G.LoginClient.CreateApiV1Login.g.cs
//HintName: G.LoginClient.CreateLogin.g.cs

#nullable enable

namespace G
{
public partial class LoginClient
{
partial void PrepareCreateApiV1LoginArguments(
partial void PrepareCreateLoginArguments(
global::System.Net.Http.HttpClient httpClient,
global::G.LoginRequest request);
partial void PrepareCreateApiV1LoginRequest(
partial void PrepareCreateLoginRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
global::G.LoginRequest request);
partial void ProcessCreateApiV1LoginResponse(
partial void ProcessCreateLoginResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessCreateApiV1LoginResponseContent(
partial void ProcessCreateLoginResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);
Expand All @@ -28,15 +28,15 @@ partial void ProcessCreateApiV1LoginResponseContent(
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> CreateApiV1LoginAsync(
public async global::System.Threading.Tasks.Task<string> CreateLoginAsync(
global::G.LoginRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareCreateApiV1LoginArguments(
PrepareCreateLoginArguments(
httpClient: _httpClient,
request: request);

Expand All @@ -52,7 +52,7 @@ partial void ProcessCreateApiV1LoginResponseContent(
PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareCreateApiV1LoginRequest(
PrepareCreateLoginRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
request: request);
Expand All @@ -65,7 +65,7 @@ partial void ProcessCreateApiV1LoginResponseContent(
ProcessResponse(
client: _httpClient,
response: response);
ProcessCreateApiV1LoginResponse(
ProcessCreateLoginResponse(
httpClient: _httpClient,
httpResponseMessage: response);

Expand All @@ -75,7 +75,7 @@ partial void ProcessCreateApiV1LoginResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessCreateApiV1LoginResponseContent(
ProcessCreateLoginResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);
Expand All @@ -101,7 +101,7 @@ partial void ProcessCreateApiV1LoginResponseContent(
/// <param name="rsaEncryptedPassword"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> CreateApiV1LoginAsync(
public async global::System.Threading.Tasks.Task<string> CreateLoginAsync(
string? username = default,
string? rsaEncryptedPassword = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand All @@ -112,7 +112,7 @@ partial void ProcessCreateApiV1LoginResponseContent(
RsaEncryptedPassword = rsaEncryptedPassword,
};

return await CreateApiV1LoginAsync(
return await CreateLoginAsync(
request: request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
Loading

0 comments on commit 71c6999

Please sign in to comment.