-
Notifications
You must be signed in to change notification settings - Fork 82
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
Adapt the types to the OpenAPI spec types #840
Comments
In #444, we switched from a map of event names and their payloads, to an approach that only uses TypeScript to infer the correct types. In order to switch to OpenAPI, I had to bring that map back. I created a PoC, beta...openapi based on my openapi types package Does anyone have an idea on how to get rid of the map, and stay with a completely typescript approach? |
I managed to create this handy utility that can help us convert the webhook event names we get from the event handler to the format used in the openapi spec type SnakeCaseToKebabCase<TString extends string> =
TString extends `${infer TPart1}_${infer TRest}`
? `${TPart1}-${SnakeCaseToKebabCase<TRest>}`
: TString; With this new utility I managed to remove most of the need for a map. |
🎉 This issue has been resolved in version 12.2.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The types will need to be adapted to make use of the OpenAPI spec.
We can make use of my package
@wolfy1339/openapi-webhooks-types
to help with the transition.Some points which I see as potential issues:
The types format is not the same, the webhooks are not on their own interface like they are currently in
@octokit/webhooks-types
.In the OpanAPI spec types, the way to get a webhook resembles like so:
Each webhook definition's name is made like so in reference to the names we accept in the event handlers
The name is seperated by
-
and dots are replaced by-
There are currently no types for events and all their possible actions, eg:
check_suite
.I'm not sure how we can get around this easily without having to resort to a lookup table. If you have any ideas, please comment
The text was updated successfully, but these errors were encountered: