Webhook payload parsing can now be done with both function and GitHub class.
from githubkit import GitHub
from githubkit.webhooks import parse_obj
parse_obj("event", payload) # defaults to latest stable schema
GitHub.webhooks.parse_obj("event", payload) # defaults to latest stable schema
GitHub.webhooks("2022-11-28").parse_obj("event", payload)
webhook parsing with event name supports type infer with overload.
from githubkit import GitHub
from githubkit.versions.latest.webhooks import PullRequestEvent
event: PullRequestEvent = GitHub.webhooks.parse_obj("pull_request", payload)
[!WARNING]
webhook models cannot be imported from githubkit.webhooks now,
use githubkit.versions.latest.models instead.
webhook types cannot be imported from githubkit.webhooks.types now,
use githubkit.versions.latest.webhooks instead.
API Versioning
API usage:
from githubkit import GitHub
g = GitHub()
# for rest api
# use latest stable version
g.rest.repos.get("owner", "repo")
# use specific version
g.rest("2022-11-28").repos.get("owner", "repo")
# for webhooks
# use latest stable version
g.webhooks.parse_obj("event", payload)
# use specific version
g.webhooks("2022-11-28").parse_obj("event", payload)
model schema usage:
# import from specific version
from githubkit.versions.v2022_11_28.models import FullRepository
# latest module always links to latest stable schema
from githubkit.versions.latest.models import FullRepository
Breakings
Webhook models and types should be imported from githubkit.versions.latest.* due to the schema migrated to openapi description
Refs
fix #9
fix #10
fix #67
related to #11
related to #54
New Features
Webhook Namespace
Webhook payload parsing can now be done with both function and GitHub class.
webhook parsing with event name supports type infer with overload.
API Versioning
API usage:
model schema usage:
Breakings
githubkit.versions.latest.*
due to the schema migrated to openapi descriptionRefs
fix #9 fix #10 fix #67 related to #11 related to #54