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

feat:Title: Update documentation for API endpoints and usage examples #39

Merged
merged 1 commit into from
Sep 27, 2024
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 @@ -5,22 +5,22 @@ namespace GitHub
{
public partial class ClassroomClient
{
partial void PrepareClassroomListAcceptedAssigmentsForAnAssignmentArguments(
partial void PrepareClassroomListAcceptedAssignmentsForAnAssignmentArguments(
global::System.Net.Http.HttpClient httpClient,
ref int assignmentId,
ref int page,
ref int perPage);
partial void PrepareClassroomListAcceptedAssigmentsForAnAssignmentRequest(
partial void PrepareClassroomListAcceptedAssignmentsForAnAssignmentRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
int assignmentId,
int page,
int perPage);
partial void ProcessClassroomListAcceptedAssigmentsForAnAssignmentResponse(
partial void ProcessClassroomListAcceptedAssignmentsForAnAssignmentResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessClassroomListAcceptedAssigmentsForAnAssignmentResponseContent(
partial void ProcessClassroomListAcceptedAssignmentsForAnAssignmentResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);
Expand All @@ -38,15 +38,15 @@ partial void ProcessClassroomListAcceptedAssigmentsForAnAssignmentResponseConten
/// </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::System.Collections.Generic.IList<global::GitHub.ClassroomAcceptedAssignment>> ClassroomListAcceptedAssigmentsForAnAssignmentAsync(
public async global::System.Threading.Tasks.Task<global::System.Collections.Generic.IList<global::GitHub.ClassroomAcceptedAssignment>> ClassroomListAcceptedAssignmentsForAnAssignmentAsync(
int assignmentId,
int page = 1,
int perPage = 30,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareClassroomListAcceptedAssigmentsForAnAssignmentArguments(
PrepareClassroomListAcceptedAssignmentsForAnAssignmentArguments(
httpClient: _httpClient,
assignmentId: ref assignmentId,
page: ref page,
Expand All @@ -59,7 +59,7 @@ partial void ProcessClassroomListAcceptedAssigmentsForAnAssignmentResponseConten
PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareClassroomListAcceptedAssigmentsForAnAssignmentRequest(
PrepareClassroomListAcceptedAssignmentsForAnAssignmentRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
assignmentId: assignmentId,
Expand All @@ -74,7 +74,7 @@ partial void ProcessClassroomListAcceptedAssigmentsForAnAssignmentResponseConten
ProcessResponse(
client: _httpClient,
response: response);
ProcessClassroomListAcceptedAssigmentsForAnAssignmentResponse(
ProcessClassroomListAcceptedAssignmentsForAnAssignmentResponse(
httpClient: _httpClient,
httpResponseMessage: response);

Expand All @@ -84,7 +84,7 @@ partial void ProcessClassroomListAcceptedAssigmentsForAnAssignmentResponseConten
client: _httpClient,
response: response,
content: ref __content);
ProcessClassroomListAcceptedAssigmentsForAnAssignmentResponseContent(
ProcessClassroomListAcceptedAssignmentsForAnAssignmentResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public sealed partial class WebhookPullRequestDequeued
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("reason")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.WebhookPullRequestDequeuedReasonJsonConverter))]
[global::System.Text.Json.Serialization.JsonRequired]
public required string Reason { get; set; }
public required global::GitHub.WebhookPullRequestDequeuedReason Reason { get; set; }

/// <summary>
/// The repository on GitHub where the event occurred. Webhook payloads contain the `repository` property<br/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

#nullable enable

namespace GitHub
{
/// <summary>
///
/// </summary>
public enum WebhookPullRequestDequeuedReason
{
/// <summary>
///
/// </summary>
UNKNOWNREMOVALREASON,
/// <summary>
///
/// </summary>
MANUAL,
/// <summary>
///
/// </summary>
MERGE,
/// <summary>
///
/// </summary>
MERGECONFLICT,
/// <summary>
///
/// </summary>
CIFAILURE,
/// <summary>
///
/// </summary>
CITIMEOUT,
/// <summary>
///
/// </summary>
ALREADYMERGED,
/// <summary>
///
/// </summary>
QUEUECLEARED,
/// <summary>
///
/// </summary>
ROLLBACK,
/// <summary>
///
/// </summary>
BRANCHPROTECTIONS,
/// <summary>
///
/// </summary>
GITTREEINVALID,
/// <summary>
///
/// </summary>
INVALIDMERGECOMMIT,
}

/// <summary>
/// Enum extensions to do fast conversions without the reflection.
/// </summary>
public static class WebhookPullRequestDequeuedReasonExtensions
{
/// <summary>
/// Converts an enum to a string.
/// </summary>
public static string ToValueString(this WebhookPullRequestDequeuedReason value)
{
return value switch
{
WebhookPullRequestDequeuedReason.UNKNOWNREMOVALREASON => "UNKNOWN_REMOVAL_REASON",
WebhookPullRequestDequeuedReason.MANUAL => "MANUAL",
WebhookPullRequestDequeuedReason.MERGE => "MERGE",
WebhookPullRequestDequeuedReason.MERGECONFLICT => "MERGE_CONFLICT",
WebhookPullRequestDequeuedReason.CIFAILURE => "CI_FAILURE",
WebhookPullRequestDequeuedReason.CITIMEOUT => "CI_TIMEOUT",
WebhookPullRequestDequeuedReason.ALREADYMERGED => "ALREADY_MERGED",
WebhookPullRequestDequeuedReason.QUEUECLEARED => "QUEUE_CLEARED",
WebhookPullRequestDequeuedReason.ROLLBACK => "ROLL_BACK",
WebhookPullRequestDequeuedReason.BRANCHPROTECTIONS => "BRANCH_PROTECTIONS",
WebhookPullRequestDequeuedReason.GITTREEINVALID => "GIT_TREE_INVALID",
WebhookPullRequestDequeuedReason.INVALIDMERGECOMMIT => "INVALID_MERGE_COMMIT",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
/// <summary>
/// Converts an string to a enum.
/// </summary>
public static WebhookPullRequestDequeuedReason? ToEnum(string value)
{
return value switch
{
"UNKNOWN_REMOVAL_REASON" => WebhookPullRequestDequeuedReason.UNKNOWNREMOVALREASON,
"MANUAL" => WebhookPullRequestDequeuedReason.MANUAL,
"MERGE" => WebhookPullRequestDequeuedReason.MERGE,
"MERGE_CONFLICT" => WebhookPullRequestDequeuedReason.MERGECONFLICT,
"CI_FAILURE" => WebhookPullRequestDequeuedReason.CIFAILURE,
"CI_TIMEOUT" => WebhookPullRequestDequeuedReason.CITIMEOUT,
"ALREADY_MERGED" => WebhookPullRequestDequeuedReason.ALREADYMERGED,
"QUEUE_CLEARED" => WebhookPullRequestDequeuedReason.QUEUECLEARED,
"ROLL_BACK" => WebhookPullRequestDequeuedReason.ROLLBACK,
"BRANCH_PROTECTIONS" => WebhookPullRequestDequeuedReason.BRANCHPROTECTIONS,
"GIT_TREE_INVALID" => WebhookPullRequestDequeuedReason.GITTREEINVALID,
"INVALID_MERGE_COMMIT" => WebhookPullRequestDequeuedReason.INVALIDMERGECOMMIT,
_ => null,
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ partial void ProcessPullsUpdateBranchResponseContent(

/// <summary>
/// Update a pull request branch<br/>
/// Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch.
/// Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch.<br/>
/// Note: If making a request on behalf of a GitHub App you must also have permissions to write the contents of the head repository.
/// </summary>
/// <param name="owner"></param>
/// <param name="repo"></param>
Expand Down Expand Up @@ -115,7 +116,8 @@ partial void ProcessPullsUpdateBranchResponseContent(

/// <summary>
/// Update a pull request branch<br/>
/// Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch.
/// Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch.<br/>
/// Note: If making a request on behalf of a GitHub App you must also have permissions to write the contents of the head repository.
/// </summary>
/// <param name="owner"></param>
/// <param name="repo"></param>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public sealed class WebhookPullRequestDequeuedReasonJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::GitHub.WebhookPullRequestDequeuedReason>
{
/// <inheritdoc />
public override global::GitHub.WebhookPullRequestDequeuedReason Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::GitHub.WebhookPullRequestDequeuedReasonExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::GitHub.WebhookPullRequestDequeuedReason)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::GitHub.WebhookPullRequestDequeuedReason value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::GitHub.WebhookPullRequestDequeuedReasonExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public sealed class WebhookPullRequestDequeuedReasonNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::GitHub.WebhookPullRequestDequeuedReason?>
{
/// <inheritdoc />
public override global::GitHub.WebhookPullRequestDequeuedReason? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::GitHub.WebhookPullRequestDequeuedReasonExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::GitHub.WebhookPullRequestDequeuedReason)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::GitHub.WebhookPullRequestDequeuedReason? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::GitHub.WebhookPullRequestDequeuedReasonExtensions.ToValueString(value.Value));
}
}
}
}
2 changes: 2 additions & 0 deletions src/libs/GitHub/Generated/JsonSerializerContext.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3517,6 +3517,8 @@ namespace GitHub
typeof(global::OpenApiGenerator.JsonConverters.WebhookPullRequestDequeuedPullRequestStateNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.WebhookPullRequestDequeuedPullRequestUserTypeJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.WebhookPullRequestDequeuedPullRequestUserTypeNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.WebhookPullRequestDequeuedReasonJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.WebhookPullRequestDequeuedReasonNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.WebhookPullRequestEditedActionJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.WebhookPullRequestEditedActionNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.WebhookPullRequestEnqueuedActionJsonConverter),
Expand Down
Loading
Loading