From 5c507897de060c1511d153727374fa73c70aafc3 Mon Sep 17 00:00:00 2001 From: Maitreyee Joshi <100631414+joshimai@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:37:34 -0400 Subject: [PATCH] Fix Duplicate Prefix Issue in OpenAPI Schema (#198) * Only prepend root_path if it's not already included in the server's URL --- pccommon/pccommon/openapi.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pccommon/pccommon/openapi.py b/pccommon/pccommon/openapi.py index 16569e1e..73f9a7c3 100644 --- a/pccommon/pccommon/openapi.py +++ b/pccommon/pccommon/openapi.py @@ -46,7 +46,13 @@ def fix_openapi_output(openapi_dict: Dict) -> None: def set_root_path(root_path: str, schema: Dict[str, Any]) -> Dict[str, Any]: def _append_root_path(k: str) -> str: - return f"{root_path}{k}" + # Only prepend root_path if it's not already included in the server's URL + if all( + root_path not in server.get("url", "") + for server in schema.get("servers", []) + ): + return f"{root_path}{k}" + return k return { **{k: v for k, v in schema.items() if k != "paths"},