2424)
2525
2626from pydantic import BaseModel , EmailStr
27+ from pydantic .fields import Deprecated as Deprecated
2728from pydantic .fields import FieldInfo as PydanticFieldInfo
2829from sqlalchemy import (
2930 Boolean ,
@@ -213,6 +214,7 @@ def Field(
213214 title : Optional [str ] = None ,
214215 description : Optional [str ] = None ,
215216 examples : Optional [list [Any ]] = None ,
217+ deprecated : Union [Deprecated , str , bool , None ] = None ,
216218 exclude : Union [Set [Union [int , str ]], Mapping [Union [int , str ], Any ], Any ] = None ,
217219 include : Union [Set [Union [int , str ]], Mapping [Union [int , str ], Any ], Any ] = None ,
218220 const : Optional [bool ] = None ,
@@ -258,6 +260,7 @@ def Field(
258260 title : Optional [str ] = None ,
259261 description : Optional [str ] = None ,
260262 examples : Optional [list [Any ]] = None ,
263+ deprecated : Union [Deprecated , str , bool , None ] = None ,
261264 exclude : Union [Set [Union [int , str ]], Mapping [Union [int , str ], Any ], Any ] = None ,
262265 include : Union [Set [Union [int , str ]], Mapping [Union [int , str ], Any ], Any ] = None ,
263266 const : Optional [bool ] = None ,
@@ -312,6 +315,7 @@ def Field(
312315 title : Optional [str ] = None ,
313316 description : Optional [str ] = None ,
314317 examples : Optional [list [Any ]] = None ,
318+ deprecated : Union [Deprecated , str , bool , None ] = None ,
315319 exclude : Union [Set [Union [int , str ]], Mapping [Union [int , str ], Any ], Any ] = None ,
316320 include : Union [Set [Union [int , str ]], Mapping [Union [int , str ], Any ], Any ] = None ,
317321 const : Optional [bool ] = None ,
@@ -347,6 +351,7 @@ def Field(
347351 title : Optional [str ] = None ,
348352 description : Optional [str ] = None ,
349353 examples : Optional [list [Any ]] = None ,
354+ deprecated : Union [Deprecated , str , bool , None ] = None ,
350355 exclude : Union [Set [Union [int , str ]], Mapping [Union [int , str ], Any ], Any ] = None ,
351356 include : Union [Set [Union [int , str ]], Mapping [Union [int , str ], Any ], Any ] = None ,
352357 const : Optional [bool ] = None ,
@@ -381,7 +386,7 @@ def Field(
381386) -> Any :
382387 current_schema_extra = schema_extra or {}
383388
384- for param_name in ("strict" , "examples" ):
389+ for param_name in ("strict" , "examples" , "deprecated" ):
385390 if param_name in current_schema_extra :
386391 msg = f"Pass `{ param_name } ` parameter directly to Field instead of passing it via `schema_extra`"
387392 warnings .warn (msg , DeprecationWarning , stacklevel = 2 )
@@ -391,11 +396,13 @@ def Field(
391396 schema_serialization_alias = current_schema_extra .pop ("serialization_alias" , None )
392397 current_strict = strict or current_schema_extra .pop ("strict" , None )
393398 current_examples = examples or current_schema_extra .pop ("examples" , None )
399+ current_deprecated = deprecated or current_schema_extra .pop ("deprecated" , None )
394400 field_info_kwargs = {
395401 "alias" : alias ,
396402 "title" : title ,
397403 "description" : description ,
398404 "examples" : current_examples ,
405+ "deprecated" : current_deprecated ,
399406 "exclude" : exclude ,
400407 "include" : include ,
401408 "const" : const ,
0 commit comments