Parse OpenAPI spec from file. Args: path: Path to OpenAPI JSON/YAML file Returns: Parsed API specification
(self, path: str)
| 92 | response = await client.get(safe_url) |
| 93 | response.raise_for_status() |
| 94 | |
| 95 | content_type = response.headers.get("content-type", "") |
| 96 | content = response.text |
| 97 | |
| 98 | if "yaml" in content_type or safe_url.endswith((".yaml", ".yml")): |
| 99 | spec = yaml.safe_load(content) |
| 100 | else: |
| 101 | spec = json.loads(content) |
| 102 | |
| 103 | return self._parse_spec(spec, safe_url) |
| 104 | |
| 105 | def parse_file(self, path: str) -> ParsedAPI: |
| 106 | """Parse OpenAPI spec from file. |
| 107 | |
| 108 | Args: |
| 109 | path: Path to OpenAPI JSON/YAML file |
| 110 | |
| 111 | Returns: |
| 112 | Parsed API specification |
| 113 | """ |
| 114 | file_path = Path(path) |
| 115 | self.logger.info(f"Parsing OpenAPI spec from {file_path}") |
| 116 |
nothing calls this directly
no test coverage detected