Skip to content

Commit

Permalink
Fix Duplicate Prefix Issue in OpenAPI Schema (#198)
Browse files Browse the repository at this point in the history
* Only prepend root_path if it's not already included in the server's URL
  • Loading branch information
joshimai authored Apr 10, 2024
1 parent f0ba6b7 commit 5c50789
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pccommon/pccommon/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 5c50789

Please sign in to comment.