Skip to content

Commit

Permalink
Merge pull request #49 from devdanzin/multiline_unicode_body
Browse files Browse the repository at this point in the history
Format request body that contains unicode as multi-line in .save_to_disk() (fix #48)
  • Loading branch information
darrenburns authored Jul 19, 2024
2 parents 1b1a41b + bab6b0b commit ee73b52
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/posting/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,15 @@ def to_httpx(self, client: httpx.AsyncClient) -> httpx.Request:
def save_to_disk(self, path: Path) -> None:
"""Save the request model to a YAML file."""
content = self.model_dump(exclude_defaults=True, exclude_none=True)
yaml_content = yaml.dump(content, None, sort_keys=False)
yaml_content = yaml.dump(
content,
None,
sort_keys=False,
allow_unicode=True,
)
encoded_content = yaml_content.encode("ascii", errors="backslashreplace")
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(yaml_content)
path.write_bytes(encoded_content)


class Contact(BaseModel):
Expand Down

0 comments on commit ee73b52

Please sign in to comment.