(spec: dict[str, Any], path: str)
| 1965 | |
| 1966 | @staticmethod |
| 1967 | def get_schema(spec: dict[str, Any], path: str) -> (list[str], dict[str, Any]): |
| 1968 | steps = [] |
| 1969 | source_path = path.strip("/") |
| 1970 | while True: |
| 1971 | if source_path.startswith('"'): |
| 1972 | if '"' not in source_path[1:]: |
| 1973 | raise ValueError(f"Unclosed quote in path: {path}") |
| 1974 | start = source_path.index('"', 1) |
| 1975 | if "/" not in source_path[start:]: |
| 1976 | steps.append(source_path) |
| 1977 | break |
| 1978 | split = source_path[start:].index("/") + start |
| 1979 | step = source_path[1 : split - 1] |
| 1980 | source_path = source_path[split + 1 :] |
| 1981 | else: |
| 1982 | if "/" not in source_path: |
| 1983 | steps.append(source_path) |
| 1984 | break |
| 1985 | step, source_path = source_path.split("/", maxsplit=1) |
| 1986 | steps.append(step) |
| 1987 | |
| 1988 | schema = spec |
| 1989 | for step in steps: |
| 1990 | if isinstance(schema, list): |
| 1991 | schema = schema[int(step)] |
| 1992 | else: |
| 1993 | schema = schema.get(step, {}) |
| 1994 | return steps, schema |
| 1995 | |
| 1996 | def get_spec_types(self, schema: dict, schema_path: list[str | int]) -> list[str]: |
| 1997 | """ |
no test coverage detected