from pathlib import Path
file_path = Path("src/apis/default_api.rs")
replacements = [
(
'return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Vulnerability>`"))),',
'serde_json::from_str(&content).map_err(Error::from),'
),
(
'return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Vulnerabilities`"))),',
'serde_json::from_str(&content).map_err(Error::from),'
)
]
lines = file_path.read_text(encoding="utf-8").splitlines()
new_lines = []
for line in lines:
for old, new in replacements:
if old in line:
line = line.replace(old, new)
new_lines.append(line)
file_path.write_text("\n".join(new_lines) + "\n", encoding="utf-8")