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),'
),
(
'return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VulnerabilityWithRelations`"))),',
'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::VulnerabilityWithComponents`"))),',
'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::Advisory`"))),',
'serde_json::from_str(&content).map_err(Error::from),'
)
]
text = file_path.read_text(encoding="utf-8")
for old, new in replacements:
text = text.replace(old, new)
file_path.write_text(text, encoding="utf-8")