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

Method get_schema

starlette/schemas.py:132–148  ·  view source on GitHub ↗
(self, routes: list[BaseRoute])

Source from the content-addressed store, hash-verified

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_schema_generationFunction · 0.45

Calls 3

get_endpointsMethod · 0.80
parse_docstringMethod · 0.80
setdefaultMethod · 0.45

Tested by 1

test_schema_generationFunction · 0.36