From 2785819aa7d367bb61aad978d81a4e0470131ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Fri, 14 Nov 2025 10:41:26 +0100 Subject: [PATCH] fix: remove trailing space from specs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien Han --- scripts/openapi_generator/schema_transforms.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/openapi_generator/schema_transforms.py b/scripts/openapi_generator/schema_transforms.py index 165d6af95..0be9874bb 100644 --- a/scripts/openapi_generator/schema_transforms.py +++ b/scripts/openapi_generator/schema_transforms.py @@ -810,6 +810,16 @@ def _write_yaml_file(file_path: Path, schema: dict[str, Any]) -> None: with open(file_path, "w") as f: yaml.dump(schema, f, default_flow_style=False, sort_keys=False) + # Post-process to remove trailing whitespace from all lines + with open(file_path) as f: + lines = f.readlines() + + # Strip trailing whitespace from each line, preserving newlines + cleaned_lines = [line.rstrip() + "\n" if line.endswith("\n") else line.rstrip() for line in lines] + + with open(file_path, "w") as f: + f.writelines(cleaned_lines) + def _fix_schema_issues(openapi_schema: dict[str, Any]) -> dict[str, Any]: """Fix common schema issues: exclusiveMinimum, null defaults, and add titles to unions."""