-
Notifications
You must be signed in to change notification settings - Fork 10
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
How do i deserialize an event payload from github app webhook json? #83
Comments
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
I recently found about the lib Octokit.Webhooks.AspNetCore, is it supposed to be used together with this GitHub.Octokit.SDK? Example of type mismatch: // take in consideration both libs installed
public sealed partial class PullRequestEventProcessor : WebhookEventProcessor
{
...
protected override async Task ProcessPullRequestWebhookAsync(
WebhookHeaders headers,
PullRequestEvent pullRequestEvent,
PullRequestAction action
)
{
...
// client is of type GitHubClient from the GitHub.Octokit.SDK package
var comments = await client
.Repos[pullRequestEvent.Repository?.Owner.Name][pullRequestEvent.Repository?.Name]
// type missmatch
.Issues[Convert.ToInt32(pullRequestEvent.Number)]
.Comments
.GetAsync();
...
} As i said, i don't really know if this is the right prop to be using from the versions that i'm using:
|
Hi @AlmirJNR! There are a couple good questions here. In general with this library, I don't think you should be deserializing anything yourself; the tool should do it for you. It's definitely confusing that there are a lot of models! Our OpenAPI specification is giant and not always perfectly normalized. In general, I've had pretty good luck by searching the API documentation for what I need, then searching the SDK for that documentation to find the model. So if I'm looking at this API endpoint to "List public events for a network of repositories", I'd search the dotnet-sdk repo for that, which would lead me to two references in the EventsRequestBuilder.cs file. Then I can take this information and mirror the pattern given in the example CLI or in the README.md file, and end up with working code that looks like this:
Does that make sense?
We haven't designed them this way, no. This SDK is generated from the OpenAPI specification as I mentioned above, and webhooks.net is hand-maintained (which means it gets less frequent updates). |
Reusable code block
In octokit.net i used to do the following:
or even when i just want the
ActivityPayload
i used to do something like:I noticed that there are a lot of types in the namespace GitHub.Models, like:
But i don't really know which one i should use.
So i would like to know how to do something like this using this new library.
The text was updated successfully, but these errors were encountered: