Internal - OpenAPI Parser

This library leverages the OpenAPI Specification to create a python client for the GitHub API. The OpenAPI specification contains metadata on all of the endpoints and how to access them properly. Using this metadata, we can construct a python client dynamically that updates automatically along with the OpenAPI Spec.


source

build_spec

def build_spec(
    nm:str='ghapi/gh_spec.py',
    url:str='https://github.com/github/rest-api-description/raw/main/descriptions/api.github.com/api.github.com.json?raw=true'
):

Regenerate the compact spec module gh_spec.py from GitHub’s OpenAPI description.

The generated gh_spec module contains the compact serialized form of the parsed spec (see SpecParser.save in fastspec): a plain-data spec dict with one entry per endpoint, e.g.:

from ghapi.gh_spec import spec
spec['ops'][3]
GhMeta(path='/app', verb='get', oper_id='apps/get-authenticated', summary='Get the authenticated app', doc_url='rest/apps/apps#get-the-authenticated-app', params=[], data=[], preview='')