From 079f8ddcfab0c3dc4b43471d95e103a62f6d16eb Mon Sep 17 00:00:00 2001 From: Pavel Knyazev Date: Thu, 8 Dec 2022 19:49:55 +0300 Subject: [PATCH] Use param.alias instead of param.name to cover both alias and name --- fastapi/dependencies/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index 2c98fd7f31..03a42418d4 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -215,7 +215,8 @@ def preserve_path_params_order(dependant: Dependant) -> Callable[[ModelField], i path_params_ordered.append(elem[1:-1]) def key(param: ModelField) -> int: - return path_params_ordered.index(param.name) + # Use param.alias to cover both alias and name + return path_params_ordered.index(param.alias) return key