MCPcopy
hub / github.com/PyGithub/PyGithub / __init__

Method __init__

scripts/openapi.py:1570–1656  ·  view source on GitHub ↗
(
        self,
        spec: dict[str, Any],
        index: dict[str, Any],
        clazz: GithubClass,
        method_name: str,
        api_verb: str,
        api_path: str,
        api_response: str | None,
        prefix_path,
        return_property: str | None,
        create_new_class_func: Callable[str] | None,
    )

Source from the content-addressed store, hash-verified

1568
1569class CreateClassMethodTransformer(CstTransformerBase):
1570 def __init__(
1571 self,
1572 spec: dict[str, Any],
1573 index: dict[str, Any],
1574 clazz: GithubClass,
1575 method_name: str,
1576 api_verb: str,
1577 api_path: str,
1578 api_response: str | None,
1579 prefix_path,
1580 return_property: str | None,
1581 create_new_class_func: Callable[str] | None,
1582 ):
1583 super().__init__()
1584 self.spec = spec
1585 self.classes = index.get("classes", {})
1586 self.schema_to_class = index.get("indices", {}).get("schema_to_classes", {})
1587 self.schema_to_class["default"] = ["GithubObject"]
1588 self.clazz = clazz
1589 self.method_name = method_name
1590 self.api_verb = api_verb
1591 self.api_path = api_path
1592 self.relative_path = api_path[len(prefix_path) :] if prefix_path else api_path
1593 self.api = spec.get("paths", {}).get(api_path, {}).get(api_verb, {})
1594 if not self.api:
1595 raise ValueError(f"Path {api_path} with verb {api_verb} does not exist in spec")
1596 self.api_descr: str | None = self.api.get("summary", None)
1597 if self.api_descr and not self.api_descr.endswith("."):
1598 self.api_descr += "."
1599 self.api_docs = self.api.get("externalDocs", {}).get("url")
1600 responses = self.api.get("responses", {})
1601 if api_response is None:
1602 if api_verb in ["get", "patch"]:
1603 api_response = "200"
1604 elif api_verb in ["post", "put"]:
1605 api_response = "200" if "200" in responses else "201"
1606 elif api_verb == "delete":
1607 api_response = "204"
1608 else:
1609 raise ValueError(f"Invalid verb {api_verb}")
1610 if api_response not in responses:
1611 raise ValueError(f"Response {api_response} does not exist for path {api_path} and verb {api_verb} in spec")
1612 self.api_response = api_response
1613 content_schema = responses.get(api_response).get("content", {}).get("application/json", {}).get("schema", None)
1614 schema_path = [
1615 "paths",
1616 self.api_path,
1617 self.api_verb,
1618 "responses",
1619 self.api_response,
1620 "content",
1621 "application/json",
1622 "schema",
1623 ]
1624 self.return_property = return_property
1625 if return_property:
1626 if content_schema is None:
1627 raise ValueError(

Callers

nothing calls this directly

Calls 4

resolve_schemaFunction · 0.85
as_python_typeFunction · 0.85
getMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected