diff --git a/fastapi/utils.py b/fastapi/utils.py index 40bff3279..774c5b982 100644 --- a/fastapi/utils.py +++ b/fastapi/utils.py @@ -137,11 +137,10 @@ def generate_operation_id_for_path( def generate_unique_id(route: "APIRoute") -> str: - operation_id = route.name + route.path_format - operation_id = re.sub("[^0-9a-zA-Z_]", "_", operation_id) + route_path_name = route.name + route.path_format + operation_id = re.sub("[^0-9a-zA-Z_]", "_", route_path_name) assert route.methods - operation_id = f"{operation_id}_{list(route.methods)[0].lower()}" - return operation_id + return f"{operation_id}_{list(route.methods)[0].lower()}" def deep_dict_update(main_dict: Dict[Any, Any], update_dict: Dict[Any, Any]) -> None: