MCPcopy
hub / github.com/encode/starlette / SchemaGenerator

Class SchemaGenerator

starlette/schemas.py:128–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126
127
128class SchemaGenerator(BaseSchemaGenerator):
129 def __init__(self, base_schema: dict[str, Any]) -> None:
130 self.base_schema = base_schema
131
132 def get_schema(self, routes: list[BaseRoute]) -> dict[str, Any]:
133 schema = dict(self.base_schema)
134 schema.setdefault("paths", {})
135 endpoints_info = self.get_endpoints(routes)
136
137 for endpoint in endpoints_info:
138 parsed = self.parse_docstring(endpoint.func)
139
140 if not parsed:
141 continue
142
143 if endpoint.path not in schema["paths"]:
144 schema["paths"][endpoint.path] = {}
145
146 schema["paths"][endpoint.path][endpoint.http_method] = parsed
147
148 return schema

Callers 1

test_schemas.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected