From 82eff7692ef0f2bd8e599581303ddd3f674b098c Mon Sep 17 00:00:00 2001 From: Justin Berger <19935354+JustinBerger@users.noreply.github.com> Date: Wed, 8 Apr 2026 07:50:54 -0700 Subject: [PATCH] fix: read swagger files with UTF-8 encoding --- aws_lambda_powertools/event_handler/api_gateway.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aws_lambda_powertools/event_handler/api_gateway.py b/aws_lambda_powertools/event_handler/api_gateway.py index 27357b5ddab..4a9fc142cf0 100644 --- a/aws_lambda_powertools/event_handler/api_gateway.py +++ b/aws_lambda_powertools/event_handler/api_gateway.py @@ -2224,8 +2224,12 @@ def swagger_handler(): # We now inject CSS and JS into the SwaggerUI file swagger_js = Path.open( Path(__file__).parent / "openapi" / "swagger_ui" / "swagger-ui-bundle.min.js", + encoding="utf-8", + ).read() + swagger_css = Path.open( + Path(__file__).parent / "openapi" / "swagger_ui" / "swagger-ui.min.css", + encoding="utf-8", ).read() - swagger_css = Path.open(Path(__file__).parent / "openapi" / "swagger_ui" / "swagger-ui.min.css").read() openapi_servers = servers or [Server(url=(base_path or "/"))]