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

Create a JSON Schema for webhook events #136

Closed
heuels opened this issue Jul 31, 2020 · 9 comments · Fixed by #186
Closed

Create a JSON Schema for webhook events #136

heuels opened this issue Jul 31, 2020 · 9 comments · Fixed by #186
Assignees
Labels
Type: Feature New feature or request

Comments

@heuels
Copy link
Contributor

heuels commented Jul 31, 2020

Following the discussion in octokit/webhooks.js#171 the plan is to manually create a JSON Schema of webhook events.

As a first step I will bootstrap the schema by feeding the examples through some generator tool (I have my eyes on https://jsonschema.net/ now, but I haven't tried it yet). The second step would take manually correcting the definitions and converting them to enums as needed.

And finally, it would be nice to use the freshly-available schema to generate TypeScript definitions in octokit/webhooks.js using bcherny/json-schema-to-typescript.

@gr2m
Copy link
Contributor

gr2m commented Jul 31, 2020

Sounds like a great plan! Thanks Egor for taking this on!

For future reference, we might consider changing the format of the published assets to follow the OpenAPI 3.1 specification for webhooks. See the webhooks field in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#fixed-fields (current a release candidate). Here is an example (see the webhooks key): https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.1/webhook-example.yaml

@gr2m
Copy link
Contributor

gr2m commented Aug 2, 2020

Another way to improve the initial JSON Schemas would be to not only parse the examples but also the "Webhook payload object" tables from the docs, e.g. https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#webhook-payload-object

@gwestersf
Copy link

Events and Webhooks team has discussed publishing a schema, but we do not have a committed roadmap date. Thanks for raising this. @bswinnerton

@gr2m
Copy link
Contributor

gr2m commented Sep 8, 2020

Hey @heuels, just checking in, are you still working on this? No rush, just want to free up the issue for others to work on in case you can't yourself

@heuels
Copy link
Contributor Author

heuels commented Sep 9, 2020

Hey! Sorry for the lack of updates for a while. I'm still working on this, although rather slowly. I hope to open a PR in a couple of weeks.

@gr2m
Copy link
Contributor

gr2m commented Sep 9, 2020

Great, thanks for the update. Let us know if you run into any questions or blockers

@heuels
Copy link
Contributor Author

heuels commented Oct 7, 2020

Hey @gr2m, sorry it took me so long, but I've opened a pull request #186 with JSON schemas for every payload type and made sure that all payloads pass validation. Could you please take a look at that and maybe we could figure out next steps there?

@gr2m
Copy link
Contributor

gr2m commented Oct 7, 2020

Thanks Egor, that's great! I'll have a look on Monday

@gr2m gr2m closed this as completed in #186 Jan 6, 2021
@octokitbot
Copy link
Collaborator

🎉 This issue has been resolved in version 3.27.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants