From 4c744c8663ee9a6c61342e80bf5b5bc9db17f7f5 Mon Sep 17 00:00:00 2001 From: Sandesh Bhandari Date: Fri, 6 Mar 2026 14:55:06 -0600 Subject: [PATCH] fix: deterministic operationId when route has multiple methods fixes #13175 --- fastapi/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastapi/utils.py b/fastapi/utils.py index 12eaa2bf08..9a8683e081 100644 --- a/fastapi/utils.py +++ b/fastapi/utils.py @@ -96,7 +96,7 @@ def generate_unique_id(route: "APIRoute") -> str: operation_id = f"{route.name}{route.path_format}" operation_id = re.sub(r"\W", "_", operation_id) assert route.methods - operation_id = f"{operation_id}_{list(route.methods)[0].lower()}" + operation_id = f"{operation_id}_{sorted(route.methods)[0].lower()}" return operation_id