You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on a generated webhook handler I noticed that the spec doesn't include a way to communicate which value X-Github-Event should hold. Currently this is the spec:
webhooks:
branch-protection-rule-created:
post:
summary: |- This event occurs when there is activity relating to branch protection rules. For more information, see "[About protected branches](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches)." For information about the APIs to manage branch protection rules, see [the GraphQL documentation](https://docs.github.com/graphql/reference/objects#branchprotectionrule) or "[Branch protection](https://docs.github.com/rest/branches/branch-protection)" in the REST API documentation. To subscribe to this event, a GitHub App must have at least read-level access for the "Administration" repository permissiondescription: A branch protection rule was created.operationId: branch-protection-rule/createdexternalDocs:
url: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch-protection-ruleparameters:
- name: User-Agentin: headerexample: GitHub-Hookshot/123abcschema:
type: string
- name: X-Github-Hook-Idin: headerexample: 12312312schema:
type: string
- name: X-Github-Eventin: headerexample: issuesschema:
type: string
- name: X-Github-Hook-Installation-Target-Idin: headerexample: 123123schema:
type: string
- name: X-Github-Hook-Installation-Target-Typein: headerexample: repositoryschema:
type: string
- name: X-GitHub-Deliveryin: headerexample: 0b989ba4-242f-11e5-81e1-c7b6966d2516schema:
type: string
- name: X-Hub-Signature-256in: headerexample: sha256=6dcb09b5b57875f334f61aebed695e2e4193db5eschema:
type: stringrequestBody:
required: truecontent:
application/json:
schema:
"$ref": "#/components/schemas/webhook-branch-protection-rule-created"responses:
'200':
description: Return a 200 status to indicate that the data was receivedsuccessfullyx-github:
githubCloudOnly: falsecategory: webhookssubcategory: branch-protection-rulesupported-webhook-types:
- repository
- organization
- app
Expected
This is what I would have expected:
webhooks:
branch-protection-rule-created:
post:
summary: |- This event occurs when there is activity relating to branch protection rules. For more information, see "[About protected branches](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches)." For information about the APIs to manage branch protection rules, see [the GraphQL documentation](https://docs.github.com/graphql/reference/objects#branchprotectionrule) or "[Branch protection](https://docs.github.com/rest/branches/branch-protection)" in the REST API documentation. To subscribe to this event, a GitHub App must have at least read-level access for the "Administration" repository permissiondescription: A branch protection rule was created.operationId: branch-protection-rule/createdexternalDocs:
url: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#branch-protection-ruleparameters:
- name: User-Agentin: headerexample: GitHub-Hookshot/123abcschema:
type: string
- name: X-Github-Hook-Idin: headerexample: 12312312schema:
type: string
- name: X-Github-Eventin: headerexample: issuesschema:
type: stringenum:
- branch-protection-rule
- name: X-Github-Hook-Installation-Target-Idin: headerexample: 123123schema:
type: string
- name: X-Github-Hook-Installation-Target-Typein: headerexample: repositoryschema:
type: string
- name: X-GitHub-Deliveryin: headerexample: 0b989ba4-242f-11e5-81e1-c7b6966d2516schema:
type: string
- name: X-Hub-Signature-256in: headerexample: sha256=6dcb09b5b57875f334f61aebed695e2e4193db5eschema:
type: stringrequestBody:
required: truecontent:
application/json:
schema:
"$ref": "#/components/schemas/webhook-branch-protection-rule-created"responses:
'200':
description: Return a 200 status to indicate that the data was receivedsuccessfullyx-github:
githubCloudOnly: falsecategory: webhookssubcategory: branch-protection-rulesupported-webhook-types:
- repository
- organization
- app
Notes
In theory it shouldn't matter that you don't specify which value the X-Github-Event holds. But by defining it for each webhook event, there is no need to validate each possible webhook schema against the request body. On top of that this will guarantee that we don't accidentally mix up two different webhooks. While in theory we could get this from the post.operationId, but that assumes we know we should ignore the / in there and everything after it, which isn't the case for all specs out there. Plus is uses dashes between words and not underscores so using that one on one also doesn't
Reproduction Steps
n/a
The text was updated successfully, but these errors were encountered:
Schema Inaccuracy
While working on a generated webhook handler I noticed that the spec doesn't include a way to communicate which value
X-Github-Event
should hold. Currently this is the spec:Expected
This is what I would have expected:
Notes
In theory it shouldn't matter that you don't specify which value the
X-Github-Event
holds. But by defining it for each webhook event, there is no need to validate each possible webhook schema against the request body. On top of that this will guarantee that we don't accidentally mix up two different webhooks. While in theory we could get this from thepost.operationId
, but that assumes we know we should ignore the/
in there and everything after it, which isn't the case for all specs out there. Plus is uses dashes between words and not underscores so using that one on one also doesn'tReproduction Steps
n/a
The text was updated successfully, but these errors were encountered: