From db83d1dcbae0c017b3eabeb17db8d8216ddbd643 Mon Sep 17 00:00:00 2001 From: yanikita <44548000+MrTheFall@users.noreply.github.com> Date: Fri, 25 Apr 2025 21:54:25 +0300 Subject: [PATCH] Use utf-8 while saving the swagger file Use utf-8 while saving the swagger file to fix "UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-1: character maps to ". Probably happens on windows without force utf-8 mode --- mitmproxy2swagger/mitmproxy2swagger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mitmproxy2swagger/mitmproxy2swagger.py b/mitmproxy2swagger/mitmproxy2swagger.py index 3f60136..8912259 100644 --- a/mitmproxy2swagger/mitmproxy2swagger.py +++ b/mitmproxy2swagger/mitmproxy2swagger.py @@ -430,7 +430,7 @@ def main(override_args: Optional[Sequence[str]] = None): "Remove the ignore: prefix to generate an endpoint with its URL\nLines that are closer to the top take precedence, the matching is greedy" ) # save the swagger file - with open(args.output, "w") as f: + with open(args.output, "w", encoding="utf-8") as f: yaml.dump(swagger, f) print("Done!")