MCPcopy Create free account
hub / github.com/TheSecuredAnalyst/security-suite / parse_file

Method parse_file

modules/apisec/openapi_parser.py:94–113  ·  view source on GitHub ↗

Parse OpenAPI spec from file. Args: path: Path to OpenAPI JSON/YAML file Returns: Parsed API specification

(self, path: str)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

_parse_specMethod · 0.95

Tested by

no test coverage detected