| 126 | |
| 127 | |
| 128 | class 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 |