Request Parameters

Here’s the reference information for the request parameters.

These are the special functions that you can put in path operation function parameters or dependency functions with Annotated to get data from the request.

It includes:

  • Query()
  • Path()
  • Body()
  • Cookie()
  • Header()
  • Form()
  • File()

You can import them all directly from fastapi:

  1. from fastapi import Body, Cookie, File, Form, Header, Path, Query

fastapi.Query

  1. Query(
  2. default=Undefined,
  3. *,
  4. default_factory=_Unset,
  5. alias=None,
  6. alias_priority=_Unset,
  7. validation_alias=None,
  8. serialization_alias=None,
  9. title=None,
  10. description=None,
  11. gt=None,
  12. ge=None,
  13. lt=None,
  14. le=None,
  15. min_length=None,
  16. max_length=None,
  17. pattern=None,
  18. regex=None,
  19. discriminator=None,
  20. strict=_Unset,
  21. multiple_of=_Unset,
  22. allow_inf_nan=_Unset,
  23. max_digits=_Unset,
  24. decimal_places=_Unset,
  25. examples=None,
  26. example=_Unset,
  27. openapi_examples=None,
  28. deprecated=None,
  29. include_in_schema=True,
  30. json_schema_extra=None,
  31. **extra
  32. )
PARAMETERDESCRIPTION
default

Default value if the parameter field is not set.

TYPE: Any DEFAULT: Undefined

default_factory

A callable to generate the default value.

This doesn’t affect Path parameters as the value is always required. The parameter is available only for compatibility.

TYPE: Union[Callable[[], Any], None] DEFAULT: _Unset

alias

An alternative name for the parameter field.

This will be used to extract the data and for the generated OpenAPI. It is particularly useful when you can’t use the name you want because it is a Python reserved keyword or similar.

TYPE: Optional[str] DEFAULT: None

alias_priority

Priority of the alias. This affects whether an alias generator is used.

TYPE: Union[int, None] DEFAULT: _Unset

validation_alias

‘Whitelist’ validation step. The parameter field will be the single one allowed by the alias or set of aliases defined.

TYPE: Union[str, None] DEFAULT: None

serialization_alias

‘Blacklist’ validation step. The vanilla parameter field will be the single one of the alias’ or set of aliases’ fields and all the other fields will be ignored at serialization time.

TYPE: Union[str, None] DEFAULT: None

title

Human-readable title.

TYPE: Optional[str] DEFAULT: None

description

Human-readable description.

TYPE: Optional[str] DEFAULT: None

gt

Greater than. If set, value must be greater than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

ge

Greater than or equal. If set, value must be greater than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

lt

Less than. If set, value must be less than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

le

Less than or equal. If set, value must be less than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

min_length

Minimum length for strings.

TYPE: Optional[int] DEFAULT: None

max_length

Maximum length for strings.

TYPE: Optional[int] DEFAULT: None

pattern

RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

regex

Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead. RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

discriminator

Parameter field name for discriminating the type in a tagged union.

TYPE: Union[str, None] DEFAULT: None

strict

If True, strict validation is applied to the field.

TYPE: Union[bool, None] DEFAULT: _Unset

multiple_of

Value must be a multiple of this. Only applicable to numbers.

TYPE: Union[float, None] DEFAULT: _Unset

allow_inf_nan

Allow inf, -inf, nan. Only applicable to numbers.

TYPE: Union[bool, None] DEFAULT: _Unset

max_digits

Maximum number of allow digits for strings.

TYPE: Union[int, None] DEFAULT: _Unset

decimal_places

Maximum number of decimal places allowed for numbers.

TYPE: Union[int, None] DEFAULT: _Unset

examples

Example values for this field.

TYPE: Optional[List[Any]] DEFAULT: None

example

Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, although still supported. Use examples instead.

TYPE: Optional[Any] DEFAULT: _Unset

openapi_examples

OpenAPI-specific examples.

It will be added to the generated OpenAPI (e.g. visible at /docs).

Swagger UI (that provides the /docs interface) has better support for the OpenAPI-specific examples than the JSON Schema examples, that’s the main use case for this.

Read more about it in the FastAPI docs for Declare Request Example Data.

TYPE: Optional[Dict[str, Example]] DEFAULT: None

deprecated

Mark this parameter field as deprecated.

It will affect the generated OpenAPI (e.g. visible at /docs).

TYPE: Optional[bool] DEFAULT: None

include_in_schema

To include (or not) this parameter field in the generated OpenAPI. You probably don’t need it, but it’s available.

This affects the generated OpenAPI (e.g. visible at /docs).

TYPE: bool DEFAULT: True

json_schema_extra

Any additional JSON schema data.

TYPE: Union[Dict[str, Any], None] DEFAULT: None

**extra

The extra kwargs is deprecated. Use json_schema_extra instead. Include extra fields used by the JSON Schema.

TYPE: Any DEFAULT: {}

Source code in fastapi/param_functions.py

  1. 339
  2. 340
  3. 341
  4. 342
  5. 343
  6. 344
  7. 345
  8. 346
  9. 347
  10. 348
  11. 349
  12. 350
  13. 351
  14. 352
  15. 353
  16. 354
  17. 355
  18. 356
  19. 357
  20. 358
  21. 359
  22. 360
  23. 361
  24. 362
  25. 363
  26. 364
  27. 365
  28. 366
  29. 367
  30. 368
  31. 369
  32. 370
  33. 371
  34. 372
  35. 373
  36. 374
  37. 375
  38. 376
  39. 377
  40. 378
  41. 379
  42. 380
  43. 381
  44. 382
  45. 383
  46. 384
  47. 385
  48. 386
  49. 387
  50. 388
  51. 389
  52. 390
  53. 391
  54. 392
  55. 393
  56. 394
  57. 395
  58. 396
  59. 397
  60. 398
  61. 399
  62. 400
  63. 401
  64. 402
  65. 403
  66. 404
  67. 405
  68. 406
  69. 407
  70. 408
  71. 409
  72. 410
  73. 411
  74. 412
  75. 413
  76. 414
  77. 415
  78. 416
  79. 417
  80. 418
  81. 419
  82. 420
  83. 421
  84. 422
  85. 423
  86. 424
  87. 425
  88. 426
  89. 427
  90. 428
  91. 429
  92. 430
  93. 431
  94. 432
  95. 433
  96. 434
  97. 435
  98. 436
  99. 437
  100. 438
  101. 439
  102. 440
  103. 441
  104. 442
  105. 443
  106. 444
  107. 445
  108. 446
  109. 447
  110. 448
  111. 449
  112. 450
  113. 451
  114. 452
  115. 453
  116. 454
  117. 455
  118. 456
  119. 457
  120. 458
  121. 459
  122. 460
  123. 461
  124. 462
  125. 463
  126. 464
  127. 465
  128. 466
  129. 467
  130. 468
  131. 469
  132. 470
  133. 471
  134. 472
  135. 473
  136. 474
  137. 475
  138. 476
  139. 477
  140. 478
  141. 479
  142. 480
  143. 481
  144. 482
  145. 483
  146. 484
  147. 485
  148. 486
  149. 487
  150. 488
  151. 489
  152. 490
  153. 491
  154. 492
  155. 493
  156. 494
  157. 495
  158. 496
  159. 497
  160. 498
  161. 499
  162. 500
  163. 501
  164. 502
  165. 503
  166. 504
  167. 505
  168. 506
  169. 507
  170. 508
  171. 509
  172. 510
  173. 511
  174. 512
  175. 513
  176. 514
  177. 515
  178. 516
  179. 517
  180. 518
  181. 519
  182. 520
  183. 521
  184. 522
  185. 523
  186. 524
  187. 525
  188. 526
  189. 527
  190. 528
  191. 529
  192. 530
  193. 531
  194. 532
  195. 533
  196. 534
  197. 535
  198. 536
  199. 537
  200. 538
  201. 539
  202. 540
  203. 541
  204. 542
  205. 543
  206. 544
  207. 545
  208. 546
  209. 547
  210. 548
  211. 549
  212. 550
  213. 551
  214. 552
  215. 553
  216. 554
  217. 555
  218. 556
  219. 557
  220. 558
  221. 559
  222. 560
  223. 561
  224. 562
  225. 563
  226. 564
  227. 565
  228. 566
  229. 567
  230. 568
  231. 569
  232. 570
  233. 571
  234. 572
  235. 573
  236. 574
  237. 575
  238. 576
  239. 577
  240. 578
  241. 579
  242. 580
  243. 581
  244. 582
  245. 583
  246. 584
  247. 585
  248. 586
  249. 587
  250. 588
  251. 589
  252. 590
  253. 591
  254. 592
  255. 593
  256. 594
  257. 595
  258. 596
  259. 597
  260. 598
  261. 599
  262. 600
  263. 601
  264. 602
  265. 603
  266. 604
  267. 605
  268. 606
  269. 607
  270. 608
  271. 609
  272. 610
  273. 611
  274. 612
  275. 613
  276. 614
  277. 615
  278. 616
  279. 617
  280. 618
  281. 619
  282. 620
  283. 621
  284. 622
  285. 623
  286. 624
  287. 625
  288. 626
  289. 627
  290. 628
  291. 629
  292. 630
  293. 631
  294. 632
  295. 633
  296. 634
  297. 635
  298. 636
  299. 637
  300. 638
  301. 639
  302. 640
  1. def Query( # noqa: N802
  2. default: Annotated[
  3. Any,
  4. Doc(
  5. “””
  6. Default value if the parameter field is not set.
  7. “””
  8. ),
  9. ] = Undefined,
  10. ,
  11. default_factory: Annotated[
  12. Union[Callable[[], Any], None],
  13. Doc(
  14. “””
  15. A callable to generate the default value.
  16. This doesnt affect Path parameters as the value is always required.
  17. The parameter is available only for compatibility.
  18. “””
  19. ),
  20. ] = _Unset,
  21. alias: Annotated[
  22. Optional[str],
  23. Doc(
  24. “””
  25. An alternative name for the parameter field.
  26. This will be used to extract the data and for the generated OpenAPI.
  27. It is particularly useful when you cant use the name you want because it
  28. is a Python reserved keyword or similar.
  29. “””
  30. ),
  31. ] = None,
  32. alias_priority: Annotated[
  33. Union[int, None],
  34. Doc(
  35. “””
  36. Priority of the alias. This affects whether an alias generator is used.
  37. “””
  38. ),
  39. ] = _Unset,
  40. # TODO: update when deprecating Pydantic v1, import these types
  41. # validation_alias: str | AliasPath | AliasChoices | None
  42. validation_alias: Annotated[
  43. Union[str, None],
  44. Doc(
  45. “””
  46. Whitelist validation step. The parameter field will be the single one
  47. allowed by the alias or set of aliases defined.
  48. “””
  49. ),
  50. ] = None,
  51. serialization_alias: Annotated[
  52. Union[str, None],
  53. Doc(
  54. “””
  55. Blacklist validation step. The vanilla parameter field will be the
  56. single one of the alias or set of aliases fields and all the other
  57. fields will be ignored at serialization time.
  58. “””
  59. ),
  60. ] = None,
  61. title: Annotated[
  62. Optional[str],
  63. Doc(
  64. “””
  65. Human-readable title.
  66. “””
  67. ),
  68. ] = None,
  69. description: Annotated[
  70. Optional[str],
  71. Doc(
  72. “””
  73. Human-readable description.
  74. “””
  75. ),
  76. ] = None,
  77. gt: Annotated[
  78. Optional[float],
  79. Doc(
  80. “””
  81. Greater than. If set, value must be greater than this. Only applicable to
  82. numbers.
  83. “””
  84. ),
  85. ] = None,
  86. ge: Annotated[
  87. Optional[float],
  88. Doc(
  89. “””
  90. Greater than or equal. If set, value must be greater than or equal to
  91. this. Only applicable to numbers.
  92. “””
  93. ),
  94. ] = None,
  95. lt: Annotated[
  96. Optional[float],
  97. Doc(
  98. “””
  99. Less than. If set, value must be less than this. Only applicable to numbers.
  100. “””
  101. ),
  102. ] = None,
  103. le: Annotated[
  104. Optional[float],
  105. Doc(
  106. “””
  107. Less than or equal. If set, value must be less than or equal to this.
  108. Only applicable to numbers.
  109. “””
  110. ),
  111. ] = None,
  112. min_length: Annotated[
  113. Optional[int],
  114. Doc(
  115. “””
  116. Minimum length for strings.
  117. “””
  118. ),
  119. ] = None,
  120. max_length: Annotated[
  121. Optional[int],
  122. Doc(
  123. “””
  124. Maximum length for strings.
  125. “””
  126. ),
  127. ] = None,
  128. pattern: Annotated[
  129. Optional[str],
  130. Doc(
  131. “””
  132. RegEx pattern for strings.
  133. “””
  134. ),
  135. ] = None,
  136. regex: Annotated[
  137. Optional[str],
  138. Doc(
  139. “””
  140. RegEx pattern for strings.
  141. “””
  142. ),
  143. deprecated(
  144. Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead.”
  145. ),
  146. ] = None,
  147. discriminator: Annotated[
  148. Union[str, None],
  149. Doc(
  150. “””
  151. Parameter field name for discriminating the type in a tagged union.
  152. “””
  153. ),
  154. ] = None,
  155. strict: Annotated[
  156. Union[bool, None],
  157. Doc(
  158. “””
  159. If True, strict validation is applied to the field.
  160. “””
  161. ),
  162. ] = _Unset,
  163. multiple_of: Annotated[
  164. Union[float, None],
  165. Doc(
  166. “””
  167. Value must be a multiple of this. Only applicable to numbers.
  168. “””
  169. ),
  170. ] = _Unset,
  171. allow_inf_nan: Annotated[
  172. Union[bool, None],
  173. Doc(
  174. “””
  175. Allow inf, -inf, nan. Only applicable to numbers.
  176. “””
  177. ),
  178. ] = _Unset,
  179. max_digits: Annotated[
  180. Union[int, None],
  181. Doc(
  182. “””
  183. Maximum number of allow digits for strings.
  184. “””
  185. ),
  186. ] = _Unset,
  187. decimal_places: Annotated[
  188. Union[int, None],
  189. Doc(
  190. “””
  191. Maximum number of decimal places allowed for numbers.
  192. “””
  193. ),
  194. ] = _Unset,
  195. examples: Annotated[
  196. Optional[List[Any]],
  197. Doc(
  198. “””
  199. Example values for this field.
  200. “””
  201. ),
  202. ] = None,
  203. example: Annotated[
  204. Optional[Any],
  205. deprecated(
  206. Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12,
  207. although still supported. Use examples instead.”
  208. ),
  209. ] = _Unset,
  210. openapi_examples: Annotated[
  211. Optional[Dict[str, Example]],
  212. Doc(
  213. “””
  214. OpenAPI-specific examples.
  215. It will be added to the generated OpenAPI (e.g. visible at /docs).
  216. Swagger UI (that provides the /docs interface) has better support for the
  217. OpenAPI-specific examples than the JSON Schema examples, thats the main
  218. use case for this.
  219. Read more about it in the
  220. FastAPI docs for Declare Request Example Data.
  221. “””
  222. ),
  223. ] = None,
  224. deprecated: Annotated[
  225. Optional[bool],
  226. Doc(
  227. “””
  228. Mark this parameter field as deprecated.
  229. It will affect the generated OpenAPI (e.g. visible at /docs).
  230. “””
  231. ),
  232. ] = None,
  233. include_in_schema: Annotated[
  234. bool,
  235. Doc(
  236. “””
  237. To include (or not) this parameter field in the generated OpenAPI.
  238. You probably dont need it, but its available.
  239. This affects the generated OpenAPI (e.g. visible at /docs).
  240. “””
  241. ),
  242. ] = True,
  243. json_schema_extra: Annotated[
  244. Union[Dict[str, Any], None],
  245. Doc(
  246. “””
  247. Any additional JSON schema data.
  248. “””
  249. ),
  250. ] = None,
  251. *extra: Annotated[
  252. Any,
  253. Doc(
  254. “””
  255. Include extra fields used by the JSON Schema.
  256. “””
  257. ),
  258. deprecated(
  259. “””
  260. The extra kwargs is deprecated. Use json_schema_extra instead.
  261. “””
  262. ),
  263. ],
  264. ) -> Any:
  265. return params.Query(
  266. default=default,
  267. default_factory=default_factory,
  268. alias=alias,
  269. alias_priority=alias_priority,
  270. validation_alias=validation_alias,
  271. serialization_alias=serialization_alias,
  272. title=title,
  273. description=description,
  274. gt=gt,
  275. ge=ge,
  276. lt=lt,
  277. le=le,
  278. min_length=min_length,
  279. max_length=max_length,
  280. pattern=pattern,
  281. regex=regex,
  282. discriminator=discriminator,
  283. strict=strict,
  284. multiple_of=multiple_of,
  285. allow_inf_nan=allow_inf_nan,
  286. max_digits=max_digits,
  287. decimal_places=decimal_places,
  288. example=example,
  289. examples=examples,
  290. openapi_examples=openapi_examples,
  291. deprecated=deprecated,
  292. include_in_schema=include_in_schema,
  293. json_schema_extra=json_schema_extra,
  294. extra,
  295. )

fastapi.Path

  1. Path(
  2. default=...,
  3. *,
  4. default_factory=_Unset,
  5. alias=None,
  6. alias_priority=_Unset,
  7. validation_alias=None,
  8. serialization_alias=None,
  9. title=None,
  10. description=None,
  11. gt=None,
  12. ge=None,
  13. lt=None,
  14. le=None,
  15. min_length=None,
  16. max_length=None,
  17. pattern=None,
  18. regex=None,
  19. discriminator=None,
  20. strict=_Unset,
  21. multiple_of=_Unset,
  22. allow_inf_nan=_Unset,
  23. max_digits=_Unset,
  24. decimal_places=_Unset,
  25. examples=None,
  26. example=_Unset,
  27. openapi_examples=None,
  28. deprecated=None,
  29. include_in_schema=True,
  30. json_schema_extra=None,
  31. **extra
  32. )

Declare a path parameter for a path operation.

Read more about it in the FastAPI docs for Path Parameters and Numeric Validations.

  1. from typing import Annotated
  2. from fastapi import FastAPI, Path
  3. app = FastAPI()
  4. @app.get("/items/{item_id}")
  5. async def read_items(
  6. item_id: Annotated[int, Path(title="The ID of the item to get")],
  7. ):
  8. return {"item_id": item_id}
PARAMETERDESCRIPTION
default

Default value if the parameter field is not set.

This doesn’t affect Path parameters as the value is always required. The parameter is available only for compatibility.

TYPE: Any DEFAULT:

default_factory

A callable to generate the default value.

This doesn’t affect Path parameters as the value is always required. The parameter is available only for compatibility.

TYPE: Union[Callable[[], Any], None] DEFAULT: _Unset

alias

An alternative name for the parameter field.

This will be used to extract the data and for the generated OpenAPI. It is particularly useful when you can’t use the name you want because it is a Python reserved keyword or similar.

TYPE: Optional[str] DEFAULT: None

alias_priority

Priority of the alias. This affects whether an alias generator is used.

TYPE: Union[int, None] DEFAULT: _Unset

validation_alias

‘Whitelist’ validation step. The parameter field will be the single one allowed by the alias or set of aliases defined.

TYPE: Union[str, None] DEFAULT: None

serialization_alias

‘Blacklist’ validation step. The vanilla parameter field will be the single one of the alias’ or set of aliases’ fields and all the other fields will be ignored at serialization time.

TYPE: Union[str, None] DEFAULT: None

title

Human-readable title.

TYPE: Optional[str] DEFAULT: None

description

Human-readable description.

TYPE: Optional[str] DEFAULT: None

gt

Greater than. If set, value must be greater than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

ge

Greater than or equal. If set, value must be greater than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

lt

Less than. If set, value must be less than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

le

Less than or equal. If set, value must be less than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

min_length

Minimum length for strings.

TYPE: Optional[int] DEFAULT: None

max_length

Maximum length for strings.

TYPE: Optional[int] DEFAULT: None

pattern

RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

regex

Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead. RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

discriminator

Parameter field name for discriminating the type in a tagged union.

TYPE: Union[str, None] DEFAULT: None

strict

If True, strict validation is applied to the field.

TYPE: Union[bool, None] DEFAULT: _Unset

multiple_of

Value must be a multiple of this. Only applicable to numbers.

TYPE: Union[float, None] DEFAULT: _Unset

allow_inf_nan

Allow inf, -inf, nan. Only applicable to numbers.

TYPE: Union[bool, None] DEFAULT: _Unset

max_digits

Maximum number of allow digits for strings.

TYPE: Union[int, None] DEFAULT: _Unset

decimal_places

Maximum number of decimal places allowed for numbers.

TYPE: Union[int, None] DEFAULT: _Unset

examples

Example values for this field.

TYPE: Optional[List[Any]] DEFAULT: None

example

Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, although still supported. Use examples instead.

TYPE: Optional[Any] DEFAULT: _Unset

openapi_examples

OpenAPI-specific examples.

It will be added to the generated OpenAPI (e.g. visible at /docs).

Swagger UI (that provides the /docs interface) has better support for the OpenAPI-specific examples than the JSON Schema examples, that’s the main use case for this.

Read more about it in the FastAPI docs for Declare Request Example Data.

TYPE: Optional[Dict[str, Example]] DEFAULT: None

deprecated

Mark this parameter field as deprecated.

It will affect the generated OpenAPI (e.g. visible at /docs).

TYPE: Optional[bool] DEFAULT: None

include_in_schema

To include (or not) this parameter field in the generated OpenAPI. You probably don’t need it, but it’s available.

This affects the generated OpenAPI (e.g. visible at /docs).

TYPE: bool DEFAULT: True

json_schema_extra

Any additional JSON schema data.

TYPE: Union[Dict[str, Any], None] DEFAULT: None

**extra

The extra kwargs is deprecated. Use json_schema_extra instead. Include extra fields used by the JSON Schema.

TYPE: Any DEFAULT: {}

Source code in fastapi/param_functions.py

  1. 11
  2. 12
  3. 13
  4. 14
  5. 15
  6. 16
  7. 17
  8. 18
  9. 19
  10. 20
  11. 21
  12. 22
  13. 23
  14. 24
  15. 25
  16. 26
  17. 27
  18. 28
  19. 29
  20. 30
  21. 31
  22. 32
  23. 33
  24. 34
  25. 35
  26. 36
  27. 37
  28. 38
  29. 39
  30. 40
  31. 41
  32. 42
  33. 43
  34. 44
  35. 45
  36. 46
  37. 47
  38. 48
  39. 49
  40. 50
  41. 51
  42. 52
  43. 53
  44. 54
  45. 55
  46. 56
  47. 57
  48. 58
  49. 59
  50. 60
  51. 61
  52. 62
  53. 63
  54. 64
  55. 65
  56. 66
  57. 67
  58. 68
  59. 69
  60. 70
  61. 71
  62. 72
  63. 73
  64. 74
  65. 75
  66. 76
  67. 77
  68. 78
  69. 79
  70. 80
  71. 81
  72. 82
  73. 83
  74. 84
  75. 85
  76. 86
  77. 87
  78. 88
  79. 89
  80. 90
  81. 91
  82. 92
  83. 93
  84. 94
  85. 95
  86. 96
  87. 97
  88. 98
  89. 99
  90. 100
  91. 101
  92. 102
  93. 103
  94. 104
  95. 105
  96. 106
  97. 107
  98. 108
  99. 109
  100. 110
  101. 111
  102. 112
  103. 113
  104. 114
  105. 115
  106. 116
  107. 117
  108. 118
  109. 119
  110. 120
  111. 121
  112. 122
  113. 123
  114. 124
  115. 125
  116. 126
  117. 127
  118. 128
  119. 129
  120. 130
  121. 131
  122. 132
  123. 133
  124. 134
  125. 135
  126. 136
  127. 137
  128. 138
  129. 139
  130. 140
  131. 141
  132. 142
  133. 143
  134. 144
  135. 145
  136. 146
  137. 147
  138. 148
  139. 149
  140. 150
  141. 151
  142. 152
  143. 153
  144. 154
  145. 155
  146. 156
  147. 157
  148. 158
  149. 159
  150. 160
  151. 161
  152. 162
  153. 163
  154. 164
  155. 165
  156. 166
  157. 167
  158. 168
  159. 169
  160. 170
  161. 171
  162. 172
  163. 173
  164. 174
  165. 175
  166. 176
  167. 177
  168. 178
  169. 179
  170. 180
  171. 181
  172. 182
  173. 183
  174. 184
  175. 185
  176. 186
  177. 187
  178. 188
  179. 189
  180. 190
  181. 191
  182. 192
  183. 193
  184. 194
  185. 195
  186. 196
  187. 197
  188. 198
  189. 199
  190. 200
  191. 201
  192. 202
  193. 203
  194. 204
  195. 205
  196. 206
  197. 207
  198. 208
  199. 209
  200. 210
  201. 211
  202. 212
  203. 213
  204. 214
  205. 215
  206. 216
  207. 217
  208. 218
  209. 219
  210. 220
  211. 221
  212. 222
  213. 223
  214. 224
  215. 225
  216. 226
  217. 227
  218. 228
  219. 229
  220. 230
  221. 231
  222. 232
  223. 233
  224. 234
  225. 235
  226. 236
  227. 237
  228. 238
  229. 239
  230. 240
  231. 241
  232. 242
  233. 243
  234. 244
  235. 245
  236. 246
  237. 247
  238. 248
  239. 249
  240. 250
  241. 251
  242. 252
  243. 253
  244. 254
  245. 255
  246. 256
  247. 257
  248. 258
  249. 259
  250. 260
  251. 261
  252. 262
  253. 263
  254. 264
  255. 265
  256. 266
  257. 267
  258. 268
  259. 269
  260. 270
  261. 271
  262. 272
  263. 273
  264. 274
  265. 275
  266. 276
  267. 277
  268. 278
  269. 279
  270. 280
  271. 281
  272. 282
  273. 283
  274. 284
  275. 285
  276. 286
  277. 287
  278. 288
  279. 289
  280. 290
  281. 291
  282. 292
  283. 293
  284. 294
  285. 295
  286. 296
  287. 297
  288. 298
  289. 299
  290. 300
  291. 301
  292. 302
  293. 303
  294. 304
  295. 305
  296. 306
  297. 307
  298. 308
  299. 309
  300. 310
  301. 311
  302. 312
  303. 313
  304. 314
  305. 315
  306. 316
  307. 317
  308. 318
  309. 319
  310. 320
  311. 321
  312. 322
  313. 323
  314. 324
  315. 325
  316. 326
  317. 327
  318. 328
  319. 329
  320. 330
  321. 331
  322. 332
  323. 333
  324. 334
  325. 335
  326. 336
def Path(  # noqa: N802
    default: Annotated[
        Any,
        Doc(
            “””
            Default value if the parameter field is not set.

            This doesn’t affect Path parameters as the value is always required.
            The parameter is available only for compatibility.
            “””
        ),
    ] = ,
    ,
    default_factory: Annotated[
        Union[Callable[[], Any], None],
        Doc(
            “””
            A callable to generate the default value.

            This doesn’t affect Path parameters as the value is always required.
            The parameter is available only for compatibility.
            “””
        ),
    ] = _Unset,
    alias: Annotated[
        Optional[str],
        Doc(
            “””
            An alternative name for the parameter field.

            This will be used to extract the data and for the generated OpenAPI.
            It is particularly useful when you can’t use the name you want because it
            is a Python reserved keyword or similar.
            “””
        ),
    ] = None,
    alias_priority: Annotated[
        Union[int, None],
        Doc(
            “””
            Priority of the alias. This affects whether an alias generator is used.
            “””
        ),
    ] = _Unset,
    # TODO: update when deprecating Pydantic v1, import these types
    # validation_alias: str | AliasPath | AliasChoices | None
    validation_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Whitelist’ validation step. The parameter field will be the single one
            allowed by the alias or set of aliases defined.
            “””
        ),
    ] = None,
    serialization_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Blacklist’ validation step. The vanilla parameter field will be the
            single one of the alias’ or set of aliases’ fields and all the other
            fields will be ignored at serialization time.
            “””
        ),
    ] = None,
    title: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable title.
            “””
        ),
    ] = None,
    description: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable description.
            “””
        ),
    ] = None,
    gt: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than. If set, value must be greater than this. Only applicable to
            numbers.
            “””
        ),
    ] = None,
    ge: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than or equal. If set, value must be greater than or equal to
            this. Only applicable to numbers.
            “””
        ),
    ] = None,
    lt: Annotated[
        Optional[float],
        Doc(
            “””
            Less than. If set, value must be less than this. Only applicable to numbers.
            “””
        ),
    ] = None,
    le: Annotated[
        Optional[float],
        Doc(
            “””
            Less than or equal. If set, value must be less than or equal to this.
            Only applicable to numbers.
            “””
        ),
    ] = None,
    min_length: Annotated[
        Optional[int],
        Doc(
            “””
            Minimum length for strings.
            “””
        ),
    ] = None,
    max_length: Annotated[
        Optional[int],
        Doc(
            “””
            Maximum length for strings.
            “””
        ),
    ] = None,
    pattern: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
    ] = None,
    regex: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
        deprecated(
            “Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead.”
        ),
    ] = None,
    discriminator: Annotated[
        Union[str, None],
        Doc(
            “””
            Parameter field name for discriminating the type in a tagged union.
            “””
        ),
    ] = None,
    strict: Annotated[
        Union[bool, None],
        Doc(
            “””
            If True, strict validation is applied to the field.
            “””
        ),
    ] = _Unset,
    multiple_of: Annotated[
        Union[float, None],
        Doc(
            “””
            Value must be a multiple of this. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    allow_inf_nan: Annotated[
        Union[bool, None],
        Doc(
            “””
            Allow inf, -inf, nan. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    max_digits: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of allow digits for strings.
            “””
        ),
    ] = _Unset,
    decimal_places: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of decimal places allowed for numbers.
            “””
        ),
    ] = _Unset,
    examples: Annotated[
        Optional[List[Any]],
        Doc(
            “””
            Example values for this field.
            “””
        ),
    ] = None,
    example: Annotated[
        Optional[Any],
        deprecated(
            “Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, “
            “although still supported. Use examples instead.”
        ),
    ] = _Unset,
    openapi_examples: Annotated[
        Optional[Dict[str, Example]],
        Doc(
            “””
            OpenAPI-specific examples.

            It will be added to the generated OpenAPI (e.g. visible at /docs).

            Swagger UI (that provides the /docs interface) has better support for the
            OpenAPI-specific examples than the JSON Schema examples, that’s the main
            use case for this.

            Read more about it in the
            FastAPI docs for Declare Request Example Data.
            “””
        ),
    ] = None,
    deprecated: Annotated[
        Optional[bool],
        Doc(
            “””
            Mark this parameter field as deprecated.

            It will affect the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = None,
    include_in_schema: Annotated[
        bool,
        Doc(
            “””
            To include (or not) this parameter field in the generated OpenAPI.
            You probably don’t need it, but it’s available.

            This affects the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = True,
    json_schema_extra: Annotated[
        Union[Dict[str, Any], None],
        Doc(
            “””
            Any additional JSON schema data.
            “””
        ),
    ] = None,
    **extra: Annotated[
        Any,
        Doc(
            “””
            Include extra fields used by the JSON Schema.
            “””
        ),
        deprecated(
            “””
            The extra kwargs is deprecated. Use json_schema_extra instead.
            “””
        ),
    ],
) -> Any:
    “””
    Declare a path parameter for a path operation.

    Read more about it in the
    FastAPI docs for Path Parameters and Numeric Validations.

    python</span>
<span>    from typing import Annotated</span>

<span>    from fastapi import FastAPI, Path</span>

<span>    app = FastAPI()</span>


<span>    @app.get("/items/{item_id}")</span>
<span>    async def read_items(</span>
<span>        item_id: Annotated[int, Path(title="The ID of the item to get")],</span>
<span>    ):</span>
<span>        return {"item_id": item_id}</span>
<span>
    “””
    return params.Path(
        default=default,
        default_factory=default_factory,
        alias=alias,
        alias_priority=alias_priority,
        validation_alias=validation_alias,
        serialization_alias=serialization_alias,
        title=title,
        description=description,
        gt=gt,
        ge=ge,
        lt=lt,
        le=le,
        min_length=min_length,
        max_length=max_length,
        pattern=pattern,
        regex=regex,
        discriminator=discriminator,
        strict=strict,
        multiple_of=multiple_of,
        allow_inf_nan=allow_inf_nan,
        max_digits=max_digits,
        decimal_places=decimal_places,
        example=example,
        examples=examples,
        openapi_examples=openapi_examples,
        deprecated=deprecated,
        include_in_schema=include_in_schema,
        json_schema_extra=json_schema_extra,
        *extra,
    )

fastapi.Body

Body(
    default=Undefined,
    *,
    default_factory=_Unset,
    embed=False,
    media_type="application/json",
    alias=None,
    alias_priority=_Unset,
    validation_alias=None,
    serialization_alias=None,
    title=None,
    description=None,
    gt=None,
    ge=None,
    lt=None,
    le=None,
    min_length=None,
    max_length=None,
    pattern=None,
    regex=None,
    discriminator=None,
    strict=_Unset,
    multiple_of=_Unset,
    allow_inf_nan=_Unset,
    max_digits=_Unset,
    decimal_places=_Unset,
    examples=None,
    example=_Unset,
    openapi_examples=None,
    deprecated=None,
    include_in_schema=True,
    json_schema_extra=None,
    **extra
)
PARAMETERDESCRIPTION
default

Default value if the parameter field is not set.

TYPE: Any DEFAULT: Undefined

default_factory

A callable to generate the default value.

This doesn’t affect Path parameters as the value is always required. The parameter is available only for compatibility.

TYPE: Union[Callable[[], Any], None] DEFAULT: _Unset

embed

When embed is True, the parameter will be expected in a JSON body as a key instead of being the JSON body itself.

This happens automatically when more than one Body parameter is declared.

Read more about it in the FastAPI docs for Body - Multiple Parameters.

TYPE: bool DEFAULT: False

media_type

The media type of this parameter field. Changing it would affect the generated OpenAPI, but currently it doesn’t affect the parsing of the data.

TYPE: str DEFAULT: ‘application/json’

alias

An alternative name for the parameter field.

This will be used to extract the data and for the generated OpenAPI. It is particularly useful when you can’t use the name you want because it is a Python reserved keyword or similar.

TYPE: Optional[str] DEFAULT: None

alias_priority

Priority of the alias. This affects whether an alias generator is used.

TYPE: Union[int, None] DEFAULT: _Unset

validation_alias

‘Whitelist’ validation step. The parameter field will be the single one allowed by the alias or set of aliases defined.

TYPE: Union[str, None] DEFAULT: None

serialization_alias

‘Blacklist’ validation step. The vanilla parameter field will be the single one of the alias’ or set of aliases’ fields and all the other fields will be ignored at serialization time.

TYPE: Union[str, None] DEFAULT: None

title

Human-readable title.

TYPE: Optional[str] DEFAULT: None

description

Human-readable description.

TYPE: Optional[str] DEFAULT: None

gt

Greater than. If set, value must be greater than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

ge

Greater than or equal. If set, value must be greater than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

lt

Less than. If set, value must be less than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

le

Less than or equal. If set, value must be less than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

min_length

Minimum length for strings.

TYPE: Optional[int] DEFAULT: None

max_length

Maximum length for strings.

TYPE: Optional[int] DEFAULT: None

pattern

RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

regex

Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead. RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

discriminator

Parameter field name for discriminating the type in a tagged union.

TYPE: Union[str, None] DEFAULT: None

strict

If True, strict validation is applied to the field.

TYPE: Union[bool, None] DEFAULT: _Unset

multiple_of

Value must be a multiple of this. Only applicable to numbers.

TYPE: Union[float, None] DEFAULT: _Unset

allow_inf_nan

Allow inf, -inf, nan. Only applicable to numbers.

TYPE: Union[bool, None] DEFAULT: _Unset

max_digits

Maximum number of allow digits for strings.

TYPE: Union[int, None] DEFAULT: _Unset

decimal_places

Maximum number of decimal places allowed for numbers.

TYPE: Union[int, None] DEFAULT: _Unset

examples

Example values for this field.

TYPE: Optional[List[Any]] DEFAULT: None

example

Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, although still supported. Use examples instead.

TYPE: Optional[Any] DEFAULT: _Unset

openapi_examples

OpenAPI-specific examples.

It will be added to the generated OpenAPI (e.g. visible at /docs).

Swagger UI (that provides the /docs interface) has better support for the OpenAPI-specific examples than the JSON Schema examples, that’s the main use case for this.

Read more about it in the FastAPI docs for Declare Request Example Data.

TYPE: Optional[Dict[str, Example]] DEFAULT: None

deprecated

Mark this parameter field as deprecated.

It will affect the generated OpenAPI (e.g. visible at /docs).

TYPE: Optional[bool] DEFAULT: None

include_in_schema

To include (or not) this parameter field in the generated OpenAPI. You probably don’t need it, but it’s available.

This affects the generated OpenAPI (e.g. visible at /docs).

TYPE: bool DEFAULT: True

json_schema_extra

Any additional JSON schema data.

TYPE: Union[Dict[str, Any], None] DEFAULT: None

**extra

The extra kwargs is deprecated. Use json_schema_extra instead. Include extra fields used by the JSON Schema.

TYPE: Any DEFAULT: {}

Source code in fastapi/param_functions.py

1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
def Body(  # noqa: N802
    default: Annotated[
        Any,
        Doc(
            “””
            Default value if the parameter field is not set.
            “””
        ),
    ] = Undefined,
    ,
    default_factory: Annotated[
        Union[Callable[[], Any], None],
        Doc(
            “””
            A callable to generate the default value.

            This doesn’t affect Path parameters as the value is always required.
            The parameter is available only for compatibility.
            “””
        ),
    ] = _Unset,
    embed: Annotated[
        bool,
        Doc(
            “””
            When embed is True, the parameter will be expected in a JSON body as a
            key instead of being the JSON body itself.

            This happens automatically when more than one Body parameter is declared.

            Read more about it in the
            FastAPI docs for Body - Multiple Parameters.
            “””
        ),
    ] = False,
    media_type: Annotated[
        str,
        Doc(
            “””
            The media type of this parameter field. Changing it would affect the
            generated OpenAPI, but currently it doesn’t affect the parsing of the data.
            “””
        ),
    ] = “application/json”,
    alias: Annotated[
        Optional[str],
        Doc(
            “””
            An alternative name for the parameter field.

            This will be used to extract the data and for the generated OpenAPI.
            It is particularly useful when you can’t use the name you want because it
            is a Python reserved keyword or similar.
            “””
        ),
    ] = None,
    alias_priority: Annotated[
        Union[int, None],
        Doc(
            “””
            Priority of the alias. This affects whether an alias generator is used.
            “””
        ),
    ] = _Unset,
    # TODO: update when deprecating Pydantic v1, import these types
    # validation_alias: str | AliasPath | AliasChoices | None
    validation_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Whitelist’ validation step. The parameter field will be the single one
            allowed by the alias or set of aliases defined.
            “””
        ),
    ] = None,
    serialization_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Blacklist’ validation step. The vanilla parameter field will be the
            single one of the alias’ or set of aliases’ fields and all the other
            fields will be ignored at serialization time.
            “””
        ),
    ] = None,
    title: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable title.
            “””
        ),
    ] = None,
    description: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable description.
            “””
        ),
    ] = None,
    gt: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than. If set, value must be greater than this. Only applicable to
            numbers.
            “””
        ),
    ] = None,
    ge: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than or equal. If set, value must be greater than or equal to
            this. Only applicable to numbers.
            “””
        ),
    ] = None,
    lt: Annotated[
        Optional[float],
        Doc(
            “””
            Less than. If set, value must be less than this. Only applicable to numbers.
            “””
        ),
    ] = None,
    le: Annotated[
        Optional[float],
        Doc(
            “””
            Less than or equal. If set, value must be less than or equal to this.
            Only applicable to numbers.
            “””
        ),
    ] = None,
    min_length: Annotated[
        Optional[int],
        Doc(
            “””
            Minimum length for strings.
            “””
        ),
    ] = None,
    max_length: Annotated[
        Optional[int],
        Doc(
            “””
            Maximum length for strings.
            “””
        ),
    ] = None,
    pattern: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
    ] = None,
    regex: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
        deprecated(
            “Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead.”
        ),
    ] = None,
    discriminator: Annotated[
        Union[str, None],
        Doc(
            “””
            Parameter field name for discriminating the type in a tagged union.
            “””
        ),
    ] = None,
    strict: Annotated[
        Union[bool, None],
        Doc(
            “””
            If True, strict validation is applied to the field.
            “””
        ),
    ] = _Unset,
    multiple_of: Annotated[
        Union[float, None],
        Doc(
            “””
            Value must be a multiple of this. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    allow_inf_nan: Annotated[
        Union[bool, None],
        Doc(
            “””
            Allow inf, -inf, nan. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    max_digits: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of allow digits for strings.
            “””
        ),
    ] = _Unset,
    decimal_places: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of decimal places allowed for numbers.
            “””
        ),
    ] = _Unset,
    examples: Annotated[
        Optional[List[Any]],
        Doc(
            “””
            Example values for this field.
            “””
        ),
    ] = None,
    example: Annotated[
        Optional[Any],
        deprecated(
            “Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, “
            “although still supported. Use examples instead.”
        ),
    ] = _Unset,
    openapi_examples: Annotated[
        Optional[Dict[str, Example]],
        Doc(
            “””
            OpenAPI-specific examples.

            It will be added to the generated OpenAPI (e.g. visible at /docs).

            Swagger UI (that provides the /docs interface) has better support for the
            OpenAPI-specific examples than the JSON Schema examples, that’s the main
            use case for this.

            Read more about it in the
            FastAPI docs for Declare Request Example Data.
            “””
        ),
    ] = None,
    deprecated: Annotated[
        Optional[bool],
        Doc(
            “””
            Mark this parameter field as deprecated.

            It will affect the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = None,
    include_in_schema: Annotated[
        bool,
        Doc(
            “””
            To include (or not) this parameter field in the generated OpenAPI.
            You probably don’t need it, but it’s available.

            This affects the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = True,
    json_schema_extra: Annotated[
        Union[Dict[str, Any], None],
        Doc(
            “””
            Any additional JSON schema data.
            “””
        ),
    ] = None,
    *extra: Annotated[
        Any,
        Doc(
            “””
            Include extra fields used by the JSON Schema.
            “””
        ),
        deprecated(
            “””
            The extra kwargs is deprecated. Use json_schema_extra instead.
            “””
        ),
    ],
) -> Any:
    return params.Body(
        default=default,
        default_factory=default_factory,
        embed=embed,
        media_type=media_type,
        alias=alias,
        alias_priority=alias_priority,
        validation_alias=validation_alias,
        serialization_alias=serialization_alias,
        title=title,
        description=description,
        gt=gt,
        ge=ge,
        lt=lt,
        le=le,
        min_length=min_length,
        max_length=max_length,
        pattern=pattern,
        regex=regex,
        discriminator=discriminator,
        strict=strict,
        multiple_of=multiple_of,
        allow_inf_nan=allow_inf_nan,
        max_digits=max_digits,
        decimal_places=decimal_places,
        example=example,
        examples=examples,
        openapi_examples=openapi_examples,
        deprecated=deprecated,
        include_in_schema=include_in_schema,
        json_schema_extra=json_schema_extra,
        extra,
    )
Cookie(
    default=Undefined,
    *,
    default_factory=_Unset,
    alias=None,
    alias_priority=_Unset,
    validation_alias=None,
    serialization_alias=None,
    title=None,
    description=None,
    gt=None,
    ge=None,
    lt=None,
    le=None,
    min_length=None,
    max_length=None,
    pattern=None,
    regex=None,
    discriminator=None,
    strict=_Unset,
    multiple_of=_Unset,
    allow_inf_nan=_Unset,
    max_digits=_Unset,
    decimal_places=_Unset,
    examples=None,
    example=_Unset,
    openapi_examples=None,
    deprecated=None,
    include_in_schema=True,
    json_schema_extra=None,
    **extra
)
PARAMETERDESCRIPTION
default

Default value if the parameter field is not set.

TYPE: Any DEFAULT: Undefined

default_factory

A callable to generate the default value.

This doesn’t affect Path parameters as the value is always required. The parameter is available only for compatibility.

TYPE: Union[Callable[[], Any], None] DEFAULT: _Unset

alias

An alternative name for the parameter field.

This will be used to extract the data and for the generated OpenAPI. It is particularly useful when you can’t use the name you want because it is a Python reserved keyword or similar.

TYPE: Optional[str] DEFAULT: None

alias_priority

Priority of the alias. This affects whether an alias generator is used.

TYPE: Union[int, None] DEFAULT: _Unset

validation_alias

‘Whitelist’ validation step. The parameter field will be the single one allowed by the alias or set of aliases defined.

TYPE: Union[str, None] DEFAULT: None

serialization_alias

‘Blacklist’ validation step. The vanilla parameter field will be the single one of the alias’ or set of aliases’ fields and all the other fields will be ignored at serialization time.

TYPE: Union[str, None] DEFAULT: None

title

Human-readable title.

TYPE: Optional[str] DEFAULT: None

description

Human-readable description.

TYPE: Optional[str] DEFAULT: None

gt

Greater than. If set, value must be greater than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

ge

Greater than or equal. If set, value must be greater than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

lt

Less than. If set, value must be less than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

le

Less than or equal. If set, value must be less than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

min_length

Minimum length for strings.

TYPE: Optional[int] DEFAULT: None

max_length

Maximum length for strings.

TYPE: Optional[int] DEFAULT: None

pattern

RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

regex

Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead. RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

discriminator

Parameter field name for discriminating the type in a tagged union.

TYPE: Union[str, None] DEFAULT: None

strict

If True, strict validation is applied to the field.

TYPE: Union[bool, None] DEFAULT: _Unset

multiple_of

Value must be a multiple of this. Only applicable to numbers.

TYPE: Union[float, None] DEFAULT: _Unset

allow_inf_nan

Allow inf, -inf, nan. Only applicable to numbers.

TYPE: Union[bool, None] DEFAULT: _Unset

max_digits

Maximum number of allow digits for strings.

TYPE: Union[int, None] DEFAULT: _Unset

decimal_places

Maximum number of decimal places allowed for numbers.

TYPE: Union[int, None] DEFAULT: _Unset

examples

Example values for this field.

TYPE: Optional[List[Any]] DEFAULT: None

example

Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, although still supported. Use examples instead.

TYPE: Optional[Any] DEFAULT: _Unset

openapi_examples

OpenAPI-specific examples.

It will be added to the generated OpenAPI (e.g. visible at /docs).

Swagger UI (that provides the /docs interface) has better support for the OpenAPI-specific examples than the JSON Schema examples, that’s the main use case for this.

Read more about it in the FastAPI docs for Declare Request Example Data.

TYPE: Optional[Dict[str, Example]] DEFAULT: None

deprecated

Mark this parameter field as deprecated.

It will affect the generated OpenAPI (e.g. visible at /docs).

TYPE: Optional[bool] DEFAULT: None

include_in_schema

To include (or not) this parameter field in the generated OpenAPI. You probably don’t need it, but it’s available.

This affects the generated OpenAPI (e.g. visible at /docs).

TYPE: bool DEFAULT: True

json_schema_extra

Any additional JSON schema data.

TYPE: Union[Dict[str, Any], None] DEFAULT: None

**extra

The extra kwargs is deprecated. Use json_schema_extra instead. Include extra fields used by the JSON Schema.

TYPE: Any DEFAULT: {}

Source code in fastapi/param_functions.py

 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
def Cookie(  # noqa: N802
    default: Annotated[
        Any,
        Doc(
            “””
            Default value if the parameter field is not set.
            “””
        ),
    ] = Undefined,
    ,
    default_factory: Annotated[
        Union[Callable[[], Any], None],
        Doc(
            “””
            A callable to generate the default value.

            This doesn’t affect Path parameters as the value is always required.
            The parameter is available only for compatibility.
            “””
        ),
    ] = _Unset,
    alias: Annotated[
        Optional[str],
        Doc(
            “””
            An alternative name for the parameter field.

            This will be used to extract the data and for the generated OpenAPI.
            It is particularly useful when you can’t use the name you want because it
            is a Python reserved keyword or similar.
            “””
        ),
    ] = None,
    alias_priority: Annotated[
        Union[int, None],
        Doc(
            “””
            Priority of the alias. This affects whether an alias generator is used.
            “””
        ),
    ] = _Unset,
    # TODO: update when deprecating Pydantic v1, import these types
    # validation_alias: str | AliasPath | AliasChoices | None
    validation_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Whitelist’ validation step. The parameter field will be the single one
            allowed by the alias or set of aliases defined.
            “””
        ),
    ] = None,
    serialization_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Blacklist’ validation step. The vanilla parameter field will be the
            single one of the alias’ or set of aliases’ fields and all the other
            fields will be ignored at serialization time.
            “””
        ),
    ] = None,
    title: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable title.
            “””
        ),
    ] = None,
    description: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable description.
            “””
        ),
    ] = None,
    gt: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than. If set, value must be greater than this. Only applicable to
            numbers.
            “””
        ),
    ] = None,
    ge: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than or equal. If set, value must be greater than or equal to
            this. Only applicable to numbers.
            “””
        ),
    ] = None,
    lt: Annotated[
        Optional[float],
        Doc(
            “””
            Less than. If set, value must be less than this. Only applicable to numbers.
            “””
        ),
    ] = None,
    le: Annotated[
        Optional[float],
        Doc(
            “””
            Less than or equal. If set, value must be less than or equal to this.
            Only applicable to numbers.
            “””
        ),
    ] = None,
    min_length: Annotated[
        Optional[int],
        Doc(
            “””
            Minimum length for strings.
            “””
        ),
    ] = None,
    max_length: Annotated[
        Optional[int],
        Doc(
            “””
            Maximum length for strings.
            “””
        ),
    ] = None,
    pattern: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
    ] = None,
    regex: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
        deprecated(
            “Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead.”
        ),
    ] = None,
    discriminator: Annotated[
        Union[str, None],
        Doc(
            “””
            Parameter field name for discriminating the type in a tagged union.
            “””
        ),
    ] = None,
    strict: Annotated[
        Union[bool, None],
        Doc(
            “””
            If True, strict validation is applied to the field.
            “””
        ),
    ] = _Unset,
    multiple_of: Annotated[
        Union[float, None],
        Doc(
            “””
            Value must be a multiple of this. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    allow_inf_nan: Annotated[
        Union[bool, None],
        Doc(
            “””
            Allow inf, -inf, nan. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    max_digits: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of allow digits for strings.
            “””
        ),
    ] = _Unset,
    decimal_places: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of decimal places allowed for numbers.
            “””
        ),
    ] = _Unset,
    examples: Annotated[
        Optional[List[Any]],
        Doc(
            “””
            Example values for this field.
            “””
        ),
    ] = None,
    example: Annotated[
        Optional[Any],
        deprecated(
            “Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, “
            “although still supported. Use examples instead.”
        ),
    ] = _Unset,
    openapi_examples: Annotated[
        Optional[Dict[str, Example]],
        Doc(
            “””
            OpenAPI-specific examples.

            It will be added to the generated OpenAPI (e.g. visible at /docs).

            Swagger UI (that provides the /docs interface) has better support for the
            OpenAPI-specific examples than the JSON Schema examples, that’s the main
            use case for this.

            Read more about it in the
            FastAPI docs for Declare Request Example Data.
            “””
        ),
    ] = None,
    deprecated: Annotated[
        Optional[bool],
        Doc(
            “””
            Mark this parameter field as deprecated.

            It will affect the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = None,
    include_in_schema: Annotated[
        bool,
        Doc(
            “””
            To include (or not) this parameter field in the generated OpenAPI.
            You probably don’t need it, but it’s available.

            This affects the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = True,
    json_schema_extra: Annotated[
        Union[Dict[str, Any], None],
        Doc(
            “””
            Any additional JSON schema data.
            “””
        ),
    ] = None,
    *extra: Annotated[
        Any,
        Doc(
            “””
            Include extra fields used by the JSON Schema.
            “””
        ),
        deprecated(
            “””
            The extra kwargs is deprecated. Use json_schema_extra instead.
            “””
        ),
    ],
) -> Any:
    return params.Cookie(
        default=default,
        default_factory=default_factory,
        alias=alias,
        alias_priority=alias_priority,
        validation_alias=validation_alias,
        serialization_alias=serialization_alias,
        title=title,
        description=description,
        gt=gt,
        ge=ge,
        lt=lt,
        le=le,
        min_length=min_length,
        max_length=max_length,
        pattern=pattern,
        regex=regex,
        discriminator=discriminator,
        strict=strict,
        multiple_of=multiple_of,
        allow_inf_nan=allow_inf_nan,
        max_digits=max_digits,
        decimal_places=decimal_places,
        example=example,
        examples=examples,
        openapi_examples=openapi_examples,
        deprecated=deprecated,
        include_in_schema=include_in_schema,
        json_schema_extra=json_schema_extra,
        extra,
    )

fastapi.Header

Header(
    default=Undefined,
    *,
    default_factory=_Unset,
    alias=None,
    alias_priority=_Unset,
    validation_alias=None,
    serialization_alias=None,
    convert_underscores=True,
    title=None,
    description=None,
    gt=None,
    ge=None,
    lt=None,
    le=None,
    min_length=None,
    max_length=None,
    pattern=None,
    regex=None,
    discriminator=None,
    strict=_Unset,
    multiple_of=_Unset,
    allow_inf_nan=_Unset,
    max_digits=_Unset,
    decimal_places=_Unset,
    examples=None,
    example=_Unset,
    openapi_examples=None,
    deprecated=None,
    include_in_schema=True,
    json_schema_extra=None,
    **extra
)
PARAMETERDESCRIPTION
default

Default value if the parameter field is not set.

TYPE: Any DEFAULT: Undefined

default_factory

A callable to generate the default value.

This doesn’t affect Path parameters as the value is always required. The parameter is available only for compatibility.

TYPE: Union[Callable[[], Any], None] DEFAULT: _Unset

alias

An alternative name for the parameter field.

This will be used to extract the data and for the generated OpenAPI. It is particularly useful when you can’t use the name you want because it is a Python reserved keyword or similar.

TYPE: Optional[str] DEFAULT: None

alias_priority

Priority of the alias. This affects whether an alias generator is used.

TYPE: Union[int, None] DEFAULT: _Unset

validation_alias

‘Whitelist’ validation step. The parameter field will be the single one allowed by the alias or set of aliases defined.

TYPE: Union[str, None] DEFAULT: None

serialization_alias

‘Blacklist’ validation step. The vanilla parameter field will be the single one of the alias’ or set of aliases’ fields and all the other fields will be ignored at serialization time.

TYPE: Union[str, None] DEFAULT: None

convert_underscores

Automatically convert underscores to hyphens in the parameter field name.

Read more about it in the FastAPI docs for Header Parameters

TYPE: bool DEFAULT: True

title

Human-readable title.

TYPE: Optional[str] DEFAULT: None

description

Human-readable description.

TYPE: Optional[str] DEFAULT: None

gt

Greater than. If set, value must be greater than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

ge

Greater than or equal. If set, value must be greater than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

lt

Less than. If set, value must be less than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

le

Less than or equal. If set, value must be less than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

min_length

Minimum length for strings.

TYPE: Optional[int] DEFAULT: None

max_length

Maximum length for strings.

TYPE: Optional[int] DEFAULT: None

pattern

RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

regex

Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead. RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

discriminator

Parameter field name for discriminating the type in a tagged union.

TYPE: Union[str, None] DEFAULT: None

strict

If True, strict validation is applied to the field.

TYPE: Union[bool, None] DEFAULT: _Unset

multiple_of

Value must be a multiple of this. Only applicable to numbers.

TYPE: Union[float, None] DEFAULT: _Unset

allow_inf_nan

Allow inf, -inf, nan. Only applicable to numbers.

TYPE: Union[bool, None] DEFAULT: _Unset

max_digits

Maximum number of allow digits for strings.

TYPE: Union[int, None] DEFAULT: _Unset

decimal_places

Maximum number of decimal places allowed for numbers.

TYPE: Union[int, None] DEFAULT: _Unset

examples

Example values for this field.

TYPE: Optional[List[Any]] DEFAULT: None

example

Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, although still supported. Use examples instead.

TYPE: Optional[Any] DEFAULT: _Unset

openapi_examples

OpenAPI-specific examples.

It will be added to the generated OpenAPI (e.g. visible at /docs).

Swagger UI (that provides the /docs interface) has better support for the OpenAPI-specific examples than the JSON Schema examples, that’s the main use case for this.

Read more about it in the FastAPI docs for Declare Request Example Data.

TYPE: Optional[Dict[str, Example]] DEFAULT: None

deprecated

Mark this parameter field as deprecated.

It will affect the generated OpenAPI (e.g. visible at /docs).

TYPE: Optional[bool] DEFAULT: None

include_in_schema

To include (or not) this parameter field in the generated OpenAPI. You probably don’t need it, but it’s available.

This affects the generated OpenAPI (e.g. visible at /docs).

TYPE: bool DEFAULT: True

json_schema_extra

Any additional JSON schema data.

TYPE: Union[Dict[str, Any], None] DEFAULT: None

**extra

The extra kwargs is deprecated. Use json_schema_extra instead. Include extra fields used by the JSON Schema.

TYPE: Any DEFAULT: {}

Source code in fastapi/param_functions.py

643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
def Header(  # noqa: N802
    default: Annotated[
        Any,
        Doc(
            “””
            Default value if the parameter field is not set.
            “””
        ),
    ] = Undefined,
    ,
    default_factory: Annotated[
        Union[Callable[[], Any], None],
        Doc(
            “””
            A callable to generate the default value.

            This doesn’t affect Path parameters as the value is always required.
            The parameter is available only for compatibility.
            “””
        ),
    ] = _Unset,
    alias: Annotated[
        Optional[str],
        Doc(
            “””
            An alternative name for the parameter field.

            This will be used to extract the data and for the generated OpenAPI.
            It is particularly useful when you can’t use the name you want because it
            is a Python reserved keyword or similar.
            “””
        ),
    ] = None,
    alias_priority: Annotated[
        Union[int, None],
        Doc(
            “””
            Priority of the alias. This affects whether an alias generator is used.
            “””
        ),
    ] = _Unset,
    # TODO: update when deprecating Pydantic v1, import these types
    # validation_alias: str | AliasPath | AliasChoices | None
    validation_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Whitelist’ validation step. The parameter field will be the single one
            allowed by the alias or set of aliases defined.
            “””
        ),
    ] = None,
    serialization_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Blacklist’ validation step. The vanilla parameter field will be the
            single one of the alias’ or set of aliases’ fields and all the other
            fields will be ignored at serialization time.
            “””
        ),
    ] = None,
    convert_underscores: Annotated[
        bool,
        Doc(
            “””
            Automatically convert underscores to hyphens in the parameter field name.

            Read more about it in the
            FastAPI docs for Header Parameters
            “””
        ),
    ] = True,
    title: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable title.
            “””
        ),
    ] = None,
    description: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable description.
            “””
        ),
    ] = None,
    gt: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than. If set, value must be greater than this. Only applicable to
            numbers.
            “””
        ),
    ] = None,
    ge: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than or equal. If set, value must be greater than or equal to
            this. Only applicable to numbers.
            “””
        ),
    ] = None,
    lt: Annotated[
        Optional[float],
        Doc(
            “””
            Less than. If set, value must be less than this. Only applicable to numbers.
            “””
        ),
    ] = None,
    le: Annotated[
        Optional[float],
        Doc(
            “””
            Less than or equal. If set, value must be less than or equal to this.
            Only applicable to numbers.
            “””
        ),
    ] = None,
    min_length: Annotated[
        Optional[int],
        Doc(
            “””
            Minimum length for strings.
            “””
        ),
    ] = None,
    max_length: Annotated[
        Optional[int],
        Doc(
            “””
            Maximum length for strings.
            “””
        ),
    ] = None,
    pattern: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
    ] = None,
    regex: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
        deprecated(
            “Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead.”
        ),
    ] = None,
    discriminator: Annotated[
        Union[str, None],
        Doc(
            “””
            Parameter field name for discriminating the type in a tagged union.
            “””
        ),
    ] = None,
    strict: Annotated[
        Union[bool, None],
        Doc(
            “””
            If True, strict validation is applied to the field.
            “””
        ),
    ] = _Unset,
    multiple_of: Annotated[
        Union[float, None],
        Doc(
            “””
            Value must be a multiple of this. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    allow_inf_nan: Annotated[
        Union[bool, None],
        Doc(
            “””
            Allow inf, -inf, nan. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    max_digits: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of allow digits for strings.
            “””
        ),
    ] = _Unset,
    decimal_places: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of decimal places allowed for numbers.
            “””
        ),
    ] = _Unset,
    examples: Annotated[
        Optional[List[Any]],
        Doc(
            “””
            Example values for this field.
            “””
        ),
    ] = None,
    example: Annotated[
        Optional[Any],
        deprecated(
            “Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, “
            “although still supported. Use examples instead.”
        ),
    ] = _Unset,
    openapi_examples: Annotated[
        Optional[Dict[str, Example]],
        Doc(
            “””
            OpenAPI-specific examples.

            It will be added to the generated OpenAPI (e.g. visible at /docs).

            Swagger UI (that provides the /docs interface) has better support for the
            OpenAPI-specific examples than the JSON Schema examples, that’s the main
            use case for this.

            Read more about it in the
            FastAPI docs for Declare Request Example Data.
            “””
        ),
    ] = None,
    deprecated: Annotated[
        Optional[bool],
        Doc(
            “””
            Mark this parameter field as deprecated.

            It will affect the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = None,
    include_in_schema: Annotated[
        bool,
        Doc(
            “””
            To include (or not) this parameter field in the generated OpenAPI.
            You probably don’t need it, but it’s available.

            This affects the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = True,
    json_schema_extra: Annotated[
        Union[Dict[str, Any], None],
        Doc(
            “””
            Any additional JSON schema data.
            “””
        ),
    ] = None,
    *extra: Annotated[
        Any,
        Doc(
            “””
            Include extra fields used by the JSON Schema.
            “””
        ),
        deprecated(
            “””
            The extra kwargs is deprecated. Use json_schema_extra instead.
            “””
        ),
    ],
) -> Any:
    return params.Header(
        default=default,
        default_factory=default_factory,
        alias=alias,
        alias_priority=alias_priority,
        validation_alias=validation_alias,
        serialization_alias=serialization_alias,
        convert_underscores=convert_underscores,
        title=title,
        description=description,
        gt=gt,
        ge=ge,
        lt=lt,
        le=le,
        min_length=min_length,
        max_length=max_length,
        pattern=pattern,
        regex=regex,
        discriminator=discriminator,
        strict=strict,
        multiple_of=multiple_of,
        allow_inf_nan=allow_inf_nan,
        max_digits=max_digits,
        decimal_places=decimal_places,
        example=example,
        examples=examples,
        openapi_examples=openapi_examples,
        deprecated=deprecated,
        include_in_schema=include_in_schema,
        json_schema_extra=json_schema_extra,
        extra,
    )

fastapi.Form

Form(
    default=Undefined,
    *,
    default_factory=_Unset,
    media_type="application/x-www-form-urlencoded",
    alias=None,
    alias_priority=_Unset,
    validation_alias=None,
    serialization_alias=None,
    title=None,
    description=None,
    gt=None,
    ge=None,
    lt=None,
    le=None,
    min_length=None,
    max_length=None,
    pattern=None,
    regex=None,
    discriminator=None,
    strict=_Unset,
    multiple_of=_Unset,
    allow_inf_nan=_Unset,
    max_digits=_Unset,
    decimal_places=_Unset,
    examples=None,
    example=_Unset,
    openapi_examples=None,
    deprecated=None,
    include_in_schema=True,
    json_schema_extra=None,
    **extra
)
PARAMETERDESCRIPTION
default

Default value if the parameter field is not set.

TYPE: Any DEFAULT: Undefined

default_factory

A callable to generate the default value.

This doesn’t affect Path parameters as the value is always required. The parameter is available only for compatibility.

TYPE: Union[Callable[[], Any], None] DEFAULT: _Unset

media_type

The media type of this parameter field. Changing it would affect the generated OpenAPI, but currently it doesn’t affect the parsing of the data.

TYPE: str DEFAULT: ‘application/x-www-form-urlencoded’

alias

An alternative name for the parameter field.

This will be used to extract the data and for the generated OpenAPI. It is particularly useful when you can’t use the name you want because it is a Python reserved keyword or similar.

TYPE: Optional[str] DEFAULT: None

alias_priority

Priority of the alias. This affects whether an alias generator is used.

TYPE: Union[int, None] DEFAULT: _Unset

validation_alias

‘Whitelist’ validation step. The parameter field will be the single one allowed by the alias or set of aliases defined.

TYPE: Union[str, None] DEFAULT: None

serialization_alias

‘Blacklist’ validation step. The vanilla parameter field will be the single one of the alias’ or set of aliases’ fields and all the other fields will be ignored at serialization time.

TYPE: Union[str, None] DEFAULT: None

title

Human-readable title.

TYPE: Optional[str] DEFAULT: None

description

Human-readable description.

TYPE: Optional[str] DEFAULT: None

gt

Greater than. If set, value must be greater than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

ge

Greater than or equal. If set, value must be greater than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

lt

Less than. If set, value must be less than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

le

Less than or equal. If set, value must be less than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

min_length

Minimum length for strings.

TYPE: Optional[int] DEFAULT: None

max_length

Maximum length for strings.

TYPE: Optional[int] DEFAULT: None

pattern

RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

regex

Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead. RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

discriminator

Parameter field name for discriminating the type in a tagged union.

TYPE: Union[str, None] DEFAULT: None

strict

If True, strict validation is applied to the field.

TYPE: Union[bool, None] DEFAULT: _Unset

multiple_of

Value must be a multiple of this. Only applicable to numbers.

TYPE: Union[float, None] DEFAULT: _Unset

allow_inf_nan

Allow inf, -inf, nan. Only applicable to numbers.

TYPE: Union[bool, None] DEFAULT: _Unset

max_digits

Maximum number of allow digits for strings.

TYPE: Union[int, None] DEFAULT: _Unset

decimal_places

Maximum number of decimal places allowed for numbers.

TYPE: Union[int, None] DEFAULT: _Unset

examples

Example values for this field.

TYPE: Optional[List[Any]] DEFAULT: None

example

Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, although still supported. Use examples instead.

TYPE: Optional[Any] DEFAULT: _Unset

openapi_examples

OpenAPI-specific examples.

It will be added to the generated OpenAPI (e.g. visible at /docs).

Swagger UI (that provides the /docs interface) has better support for the OpenAPI-specific examples than the JSON Schema examples, that’s the main use case for this.

Read more about it in the FastAPI docs for Declare Request Example Data.

TYPE: Optional[Dict[str, Example]] DEFAULT: None

deprecated

Mark this parameter field as deprecated.

It will affect the generated OpenAPI (e.g. visible at /docs).

TYPE: Optional[bool] DEFAULT: None

include_in_schema

To include (or not) this parameter field in the generated OpenAPI. You probably don’t need it, but it’s available.

This affects the generated OpenAPI (e.g. visible at /docs).

TYPE: bool DEFAULT: True

json_schema_extra

Any additional JSON schema data.

TYPE: Union[Dict[str, Any], None] DEFAULT: None

**extra

The extra kwargs is deprecated. Use json_schema_extra instead. Include extra fields used by the JSON Schema.

TYPE: Any DEFAULT: {}

Source code in fastapi/param_functions.py

1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
def Form(  # noqa: N802
    default: Annotated[
        Any,
        Doc(
            “””
            Default value if the parameter field is not set.
            “””
        ),
    ] = Undefined,
    ,
    default_factory: Annotated[
        Union[Callable[[], Any], None],
        Doc(
            “””
            A callable to generate the default value.

            This doesn’t affect Path parameters as the value is always required.
            The parameter is available only for compatibility.
            “””
        ),
    ] = _Unset,
    media_type: Annotated[
        str,
        Doc(
            “””
            The media type of this parameter field. Changing it would affect the
            generated OpenAPI, but currently it doesn’t affect the parsing of the data.
            “””
        ),
    ] = “application/x-www-form-urlencoded”,
    alias: Annotated[
        Optional[str],
        Doc(
            “””
            An alternative name for the parameter field.

            This will be used to extract the data and for the generated OpenAPI.
            It is particularly useful when you can’t use the name you want because it
            is a Python reserved keyword or similar.
            “””
        ),
    ] = None,
    alias_priority: Annotated[
        Union[int, None],
        Doc(
            “””
            Priority of the alias. This affects whether an alias generator is used.
            “””
        ),
    ] = _Unset,
    # TODO: update when deprecating Pydantic v1, import these types
    # validation_alias: str | AliasPath | AliasChoices | None
    validation_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Whitelist’ validation step. The parameter field will be the single one
            allowed by the alias or set of aliases defined.
            “””
        ),
    ] = None,
    serialization_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Blacklist’ validation step. The vanilla parameter field will be the
            single one of the alias’ or set of aliases’ fields and all the other
            fields will be ignored at serialization time.
            “””
        ),
    ] = None,
    title: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable title.
            “””
        ),
    ] = None,
    description: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable description.
            “””
        ),
    ] = None,
    gt: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than. If set, value must be greater than this. Only applicable to
            numbers.
            “””
        ),
    ] = None,
    ge: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than or equal. If set, value must be greater than or equal to
            this. Only applicable to numbers.
            “””
        ),
    ] = None,
    lt: Annotated[
        Optional[float],
        Doc(
            “””
            Less than. If set, value must be less than this. Only applicable to numbers.
            “””
        ),
    ] = None,
    le: Annotated[
        Optional[float],
        Doc(
            “””
            Less than or equal. If set, value must be less than or equal to this.
            Only applicable to numbers.
            “””
        ),
    ] = None,
    min_length: Annotated[
        Optional[int],
        Doc(
            “””
            Minimum length for strings.
            “””
        ),
    ] = None,
    max_length: Annotated[
        Optional[int],
        Doc(
            “””
            Maximum length for strings.
            “””
        ),
    ] = None,
    pattern: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
    ] = None,
    regex: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
        deprecated(
            “Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead.”
        ),
    ] = None,
    discriminator: Annotated[
        Union[str, None],
        Doc(
            “””
            Parameter field name for discriminating the type in a tagged union.
            “””
        ),
    ] = None,
    strict: Annotated[
        Union[bool, None],
        Doc(
            “””
            If True, strict validation is applied to the field.
            “””
        ),
    ] = _Unset,
    multiple_of: Annotated[
        Union[float, None],
        Doc(
            “””
            Value must be a multiple of this. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    allow_inf_nan: Annotated[
        Union[bool, None],
        Doc(
            “””
            Allow inf, -inf, nan. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    max_digits: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of allow digits for strings.
            “””
        ),
    ] = _Unset,
    decimal_places: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of decimal places allowed for numbers.
            “””
        ),
    ] = _Unset,
    examples: Annotated[
        Optional[List[Any]],
        Doc(
            “””
            Example values for this field.
            “””
        ),
    ] = None,
    example: Annotated[
        Optional[Any],
        deprecated(
            “Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, “
            “although still supported. Use examples instead.”
        ),
    ] = _Unset,
    openapi_examples: Annotated[
        Optional[Dict[str, Example]],
        Doc(
            “””
            OpenAPI-specific examples.

            It will be added to the generated OpenAPI (e.g. visible at /docs).

            Swagger UI (that provides the /docs interface) has better support for the
            OpenAPI-specific examples than the JSON Schema examples, that’s the main
            use case for this.

            Read more about it in the
            FastAPI docs for Declare Request Example Data.
            “””
        ),
    ] = None,
    deprecated: Annotated[
        Optional[bool],
        Doc(
            “””
            Mark this parameter field as deprecated.

            It will affect the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = None,
    include_in_schema: Annotated[
        bool,
        Doc(
            “””
            To include (or not) this parameter field in the generated OpenAPI.
            You probably don’t need it, but it’s available.

            This affects the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = True,
    json_schema_extra: Annotated[
        Union[Dict[str, Any], None],
        Doc(
            “””
            Any additional JSON schema data.
            “””
        ),
    ] = None,
    *extra: Annotated[
        Any,
        Doc(
            “””
            Include extra fields used by the JSON Schema.
            “””
        ),
        deprecated(
            “””
            The extra kwargs is deprecated. Use json_schema_extra instead.
            “””
        ),
    ],
) -> Any:
    return params.Form(
        default=default,
        default_factory=default_factory,
        media_type=media_type,
        alias=alias,
        alias_priority=alias_priority,
        validation_alias=validation_alias,
        serialization_alias=serialization_alias,
        title=title,
        description=description,
        gt=gt,
        ge=ge,
        lt=lt,
        le=le,
        min_length=min_length,
        max_length=max_length,
        pattern=pattern,
        regex=regex,
        discriminator=discriminator,
        strict=strict,
        multiple_of=multiple_of,
        allow_inf_nan=allow_inf_nan,
        max_digits=max_digits,
        decimal_places=decimal_places,
        example=example,
        examples=examples,
        openapi_examples=openapi_examples,
        deprecated=deprecated,
        include_in_schema=include_in_schema,
        json_schema_extra=json_schema_extra,
        extra,
    )

fastapi.File

File(
    default=Undefined,
    *,
    default_factory=_Unset,
    media_type="multipart/form-data",
    alias=None,
    alias_priority=_Unset,
    validation_alias=None,
    serialization_alias=None,
    title=None,
    description=None,
    gt=None,
    ge=None,
    lt=None,
    le=None,
    min_length=None,
    max_length=None,
    pattern=None,
    regex=None,
    discriminator=None,
    strict=_Unset,
    multiple_of=_Unset,
    allow_inf_nan=_Unset,
    max_digits=_Unset,
    decimal_places=_Unset,
    examples=None,
    example=_Unset,
    openapi_examples=None,
    deprecated=None,
    include_in_schema=True,
    json_schema_extra=None,
    **extra
)
PARAMETERDESCRIPTION
default

Default value if the parameter field is not set.

TYPE: Any DEFAULT: Undefined

default_factory

A callable to generate the default value.

This doesn’t affect Path parameters as the value is always required. The parameter is available only for compatibility.

TYPE: Union[Callable[[], Any], None] DEFAULT: _Unset

media_type

The media type of this parameter field. Changing it would affect the generated OpenAPI, but currently it doesn’t affect the parsing of the data.

TYPE: str DEFAULT: ‘multipart/form-data’

alias

An alternative name for the parameter field.

This will be used to extract the data and for the generated OpenAPI. It is particularly useful when you can’t use the name you want because it is a Python reserved keyword or similar.

TYPE: Optional[str] DEFAULT: None

alias_priority

Priority of the alias. This affects whether an alias generator is used.

TYPE: Union[int, None] DEFAULT: _Unset

validation_alias

‘Whitelist’ validation step. The parameter field will be the single one allowed by the alias or set of aliases defined.

TYPE: Union[str, None] DEFAULT: None

serialization_alias

‘Blacklist’ validation step. The vanilla parameter field will be the single one of the alias’ or set of aliases’ fields and all the other fields will be ignored at serialization time.

TYPE: Union[str, None] DEFAULT: None

title

Human-readable title.

TYPE: Optional[str] DEFAULT: None

description

Human-readable description.

TYPE: Optional[str] DEFAULT: None

gt

Greater than. If set, value must be greater than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

ge

Greater than or equal. If set, value must be greater than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

lt

Less than. If set, value must be less than this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

le

Less than or equal. If set, value must be less than or equal to this. Only applicable to numbers.

TYPE: Optional[float] DEFAULT: None

min_length

Minimum length for strings.

TYPE: Optional[int] DEFAULT: None

max_length

Maximum length for strings.

TYPE: Optional[int] DEFAULT: None

pattern

RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

regex

Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead. RegEx pattern for strings.

TYPE: Optional[str] DEFAULT: None

discriminator

Parameter field name for discriminating the type in a tagged union.

TYPE: Union[str, None] DEFAULT: None

strict

If True, strict validation is applied to the field.

TYPE: Union[bool, None] DEFAULT: _Unset

multiple_of

Value must be a multiple of this. Only applicable to numbers.

TYPE: Union[float, None] DEFAULT: _Unset

allow_inf_nan

Allow inf, -inf, nan. Only applicable to numbers.

TYPE: Union[bool, None] DEFAULT: _Unset

max_digits

Maximum number of allow digits for strings.

TYPE: Union[int, None] DEFAULT: _Unset

decimal_places

Maximum number of decimal places allowed for numbers.

TYPE: Union[int, None] DEFAULT: _Unset

examples

Example values for this field.

TYPE: Optional[List[Any]] DEFAULT: None

example

Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, although still supported. Use examples instead.

TYPE: Optional[Any] DEFAULT: _Unset

openapi_examples

OpenAPI-specific examples.

It will be added to the generated OpenAPI (e.g. visible at /docs).

Swagger UI (that provides the /docs interface) has better support for the OpenAPI-specific examples than the JSON Schema examples, that’s the main use case for this.

Read more about it in the FastAPI docs for Declare Request Example Data.

TYPE: Optional[Dict[str, Example]] DEFAULT: None

deprecated

Mark this parameter field as deprecated.

It will affect the generated OpenAPI (e.g. visible at /docs).

TYPE: Optional[bool] DEFAULT: None

include_in_schema

To include (or not) this parameter field in the generated OpenAPI. You probably don’t need it, but it’s available.

This affects the generated OpenAPI (e.g. visible at /docs).

TYPE: bool DEFAULT: True

json_schema_extra

Any additional JSON schema data.

TYPE: Union[Dict[str, Any], None] DEFAULT: None

**extra

The extra kwargs is deprecated. Use json_schema_extra instead. Include extra fields used by the JSON Schema.

TYPE: Any DEFAULT: {}

Source code in fastapi/param_functions.py

1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
def File(  # noqa: N802
    default: Annotated[
        Any,
        Doc(
            “””
            Default value if the parameter field is not set.
            “””
        ),
    ] = Undefined,
    ,
    default_factory: Annotated[
        Union[Callable[[], Any], None],
        Doc(
            “””
            A callable to generate the default value.

            This doesn’t affect Path parameters as the value is always required.
            The parameter is available only for compatibility.
            “””
        ),
    ] = _Unset,
    media_type: Annotated[
        str,
        Doc(
            “””
            The media type of this parameter field. Changing it would affect the
            generated OpenAPI, but currently it doesn’t affect the parsing of the data.
            “””
        ),
    ] = “multipart/form-data”,
    alias: Annotated[
        Optional[str],
        Doc(
            “””
            An alternative name for the parameter field.

            This will be used to extract the data and for the generated OpenAPI.
            It is particularly useful when you can’t use the name you want because it
            is a Python reserved keyword or similar.
            “””
        ),
    ] = None,
    alias_priority: Annotated[
        Union[int, None],
        Doc(
            “””
            Priority of the alias. This affects whether an alias generator is used.
            “””
        ),
    ] = _Unset,
    # TODO: update when deprecating Pydantic v1, import these types
    # validation_alias: str | AliasPath | AliasChoices | None
    validation_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Whitelist’ validation step. The parameter field will be the single one
            allowed by the alias or set of aliases defined.
            “””
        ),
    ] = None,
    serialization_alias: Annotated[
        Union[str, None],
        Doc(
            “””
            ‘Blacklist’ validation step. The vanilla parameter field will be the
            single one of the alias’ or set of aliases’ fields and all the other
            fields will be ignored at serialization time.
            “””
        ),
    ] = None,
    title: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable title.
            “””
        ),
    ] = None,
    description: Annotated[
        Optional[str],
        Doc(
            “””
            Human-readable description.
            “””
        ),
    ] = None,
    gt: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than. If set, value must be greater than this. Only applicable to
            numbers.
            “””
        ),
    ] = None,
    ge: Annotated[
        Optional[float],
        Doc(
            “””
            Greater than or equal. If set, value must be greater than or equal to
            this. Only applicable to numbers.
            “””
        ),
    ] = None,
    lt: Annotated[
        Optional[float],
        Doc(
            “””
            Less than. If set, value must be less than this. Only applicable to numbers.
            “””
        ),
    ] = None,
    le: Annotated[
        Optional[float],
        Doc(
            “””
            Less than or equal. If set, value must be less than or equal to this.
            Only applicable to numbers.
            “””
        ),
    ] = None,
    min_length: Annotated[
        Optional[int],
        Doc(
            “””
            Minimum length for strings.
            “””
        ),
    ] = None,
    max_length: Annotated[
        Optional[int],
        Doc(
            “””
            Maximum length for strings.
            “””
        ),
    ] = None,
    pattern: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
    ] = None,
    regex: Annotated[
        Optional[str],
        Doc(
            “””
            RegEx pattern for strings.
            “””
        ),
        deprecated(
            “Deprecated in FastAPI 0.100.0 and Pydantic v2, use pattern instead.”
        ),
    ] = None,
    discriminator: Annotated[
        Union[str, None],
        Doc(
            “””
            Parameter field name for discriminating the type in a tagged union.
            “””
        ),
    ] = None,
    strict: Annotated[
        Union[bool, None],
        Doc(
            “””
            If True, strict validation is applied to the field.
            “””
        ),
    ] = _Unset,
    multiple_of: Annotated[
        Union[float, None],
        Doc(
            “””
            Value must be a multiple of this. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    allow_inf_nan: Annotated[
        Union[bool, None],
        Doc(
            “””
            Allow inf, -inf, nan. Only applicable to numbers.
            “””
        ),
    ] = _Unset,
    max_digits: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of allow digits for strings.
            “””
        ),
    ] = _Unset,
    decimal_places: Annotated[
        Union[int, None],
        Doc(
            “””
            Maximum number of decimal places allowed for numbers.
            “””
        ),
    ] = _Unset,
    examples: Annotated[
        Optional[List[Any]],
        Doc(
            “””
            Example values for this field.
            “””
        ),
    ] = None,
    example: Annotated[
        Optional[Any],
        deprecated(
            “Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, “
            “although still supported. Use examples instead.”
        ),
    ] = _Unset,
    openapi_examples: Annotated[
        Optional[Dict[str, Example]],
        Doc(
            “””
            OpenAPI-specific examples.

            It will be added to the generated OpenAPI (e.g. visible at /docs).

            Swagger UI (that provides the /docs interface) has better support for the
            OpenAPI-specific examples than the JSON Schema examples, that’s the main
            use case for this.

            Read more about it in the
            FastAPI docs for Declare Request Example Data.
            “””
        ),
    ] = None,
    deprecated: Annotated[
        Optional[bool],
        Doc(
            “””
            Mark this parameter field as deprecated.

            It will affect the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = None,
    include_in_schema: Annotated[
        bool,
        Doc(
            “””
            To include (or not) this parameter field in the generated OpenAPI.
            You probably don’t need it, but it’s available.

            This affects the generated OpenAPI (e.g. visible at /docs).
            “””
        ),
    ] = True,
    json_schema_extra: Annotated[
        Union[Dict[str, Any], None],
        Doc(
            “””
            Any additional JSON schema data.
            “””
        ),
    ] = None,
    *extra: Annotated[
        Any,
        Doc(
            “””
            Include extra fields used by the JSON Schema.
            “””
        ),
        deprecated(
            “””
            The extra kwargs is deprecated. Use json_schema_extra instead.
            “””
        ),
    ],
) -> Any:
    return params.File(
        default=default,
        default_factory=default_factory,
        media_type=media_type,
        alias=alias,
        alias_priority=alias_priority,
        validation_alias=validation_alias,
        serialization_alias=serialization_alias,
        title=title,
        description=description,
        gt=gt,
        ge=ge,
        lt=lt,
        le=le,
        min_length=min_length,
        max_length=max_length,
        pattern=pattern,
        regex=regex,
        discriminator=discriminator,
        strict=strict,
        multiple_of=multiple_of,
        allow_inf_nan=allow_inf_nan,
        max_digits=max_digits,
        decimal_places=decimal_places,
        example=example,
        examples=examples,
        openapi_examples=openapi_examples,
        deprecated=deprecated,
        include_in_schema=include_in_schema,
        json_schema_extra=json_schema_extra,
        extra,
    )