From 4e50f534591d2a9c286a33e7eef5463b1fd8a1fd Mon Sep 17 00:00:00 2001 From: James Addison Date: Sun, 24 Nov 2019 05:23:33 -0800 Subject: [PATCH] :bug: Fixing validator-caused incorrect output key order (#637) --- fastapi/utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fastapi/utils.py b/fastapi/utils.py index 8cb0ec123..9e4210f86 100644 --- a/fastapi/utils.py +++ b/fastapi/utils.py @@ -59,12 +59,11 @@ def create_cloned_field(field: Field) -> Field: if lenient_issubclass(original_type, BaseModel): original_type = cast(Type[BaseModel], original_type) use_type = create_model( - original_type.__name__, - __config__=original_type.__config__, - __validators__=original_type.__validators__, # type: ignore + original_type.__name__, __config__=original_type.__config__ ) for f in original_type.__fields__.values(): use_type.__fields__[f.name] = f + use_type.__validators__ = original_type.__validators__ new_field = Field( name=field.name, type_=use_type,