yanyongyu / githubkit

The modern, all-batteries-included GitHub SDK for Python, including rest api, graphql, webhooks, like octokit!
MIT License
158 stars 21 forks source link

Feature: Add a link to the Github docs for each REST endpoint #87

Closed eric-nguyen-cs closed 5 months ago

eric-nguyen-cs commented 5 months ago

I believe that Github provides a link to the Github docs for each REST endpoint in the api definition json so it would be possible to add a link to the docs for each Python endpoint function For example

  async def async_get_branch(
      self,
      owner: str,
      repo: str,
      branch: str,
      *,
      headers: Optional[Dict[str, str]] = None,
  ) -> Response[BranchWithProtection]:
      """see more `https://docs.github.com/en/rest/branches/branches?apiVersion=2022-11-28#get-a-branch`"""
      from ..models import BasicError, BranchWithProtection

      url = f"/repos/{owner}/{repo}/branches/{branch}"

      headers = {"X-GitHub-Api-Version": self._REST_API_VERSION, **(headers or {})}

      return await self._github.arequest(
          "GET",
          url,
          headers=exclude_unset(headers),
          response_model=BranchWithProtection,
          error_models={
              "404": BasicError,
          },
      )
eric-nguyen-cs commented 5 months ago

I'd be willing to do the PR as well

yanyongyu commented 5 months ago

This looks great! The docs link for each endpoint can be get from the externalDocs.url field of the schema.