Coverage for fastapi/param_functions.py: 100%
25 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-04 08:29 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-04 08:29 +0000
1from typing import Any, Callable, Dict, List, Optional, Sequence, Union 1abcdefg
3from annotated_doc import Doc 1abcdefg
4from fastapi import params 1abcdefg
5from fastapi._compat import Undefined 1abcdefg
6from fastapi.openapi.models import Example 1abcdefg
7from typing_extensions import Annotated, Literal, deprecated 1abcdefg
9_Unset: Any = Undefined 1abcdefg
12def Path( # noqa: N802 1abcdefg
13 default: Annotated[
14 Any,
15 Doc(
16 """
17 Default value if the parameter field is not set.
19 This doesn't affect `Path` parameters as the value is always required.
20 The parameter is available only for compatibility.
21 """
22 ),
23 ] = ...,
24 *,
25 default_factory: Annotated[
26 Union[Callable[[], Any], None],
27 Doc(
28 """
29 A callable to generate the default value.
31 This doesn't affect `Path` parameters as the value is always required.
32 The parameter is available only for compatibility.
33 """
34 ),
35 ] = _Unset,
36 alias: Annotated[
37 Optional[str],
38 Doc(
39 """
40 An alternative name for the parameter field.
42 This will be used to extract the data and for the generated OpenAPI.
43 It is particularly useful when you can't use the name you want because it
44 is a Python reserved keyword or similar.
45 """
46 ),
47 ] = None,
48 alias_priority: Annotated[
49 Union[int, None],
50 Doc(
51 """
52 Priority of the alias. This affects whether an alias generator is used.
53 """
54 ),
55 ] = _Unset,
56 # TODO: update when deprecating Pydantic v1, import these types
57 # validation_alias: str | AliasPath | AliasChoices | None
58 validation_alias: Annotated[
59 Union[str, None],
60 Doc(
61 """
62 'Whitelist' validation step. The parameter field will be the single one
63 allowed by the alias or set of aliases defined.
64 """
65 ),
66 ] = None,
67 serialization_alias: Annotated[
68 Union[str, None],
69 Doc(
70 """
71 'Blacklist' validation step. The vanilla parameter field will be the
72 single one of the alias' or set of aliases' fields and all the other
73 fields will be ignored at serialization time.
74 """
75 ),
76 ] = None,
77 title: Annotated[
78 Optional[str],
79 Doc(
80 """
81 Human-readable title.
82 """
83 ),
84 ] = None,
85 description: Annotated[
86 Optional[str],
87 Doc(
88 """
89 Human-readable description.
90 """
91 ),
92 ] = None,
93 gt: Annotated[
94 Optional[float],
95 Doc(
96 """
97 Greater than. If set, value must be greater than this. Only applicable to
98 numbers.
99 """
100 ),
101 ] = None,
102 ge: Annotated[
103 Optional[float],
104 Doc(
105 """
106 Greater than or equal. If set, value must be greater than or equal to
107 this. Only applicable to numbers.
108 """
109 ),
110 ] = None,
111 lt: Annotated[
112 Optional[float],
113 Doc(
114 """
115 Less than. If set, value must be less than this. Only applicable to numbers.
116 """
117 ),
118 ] = None,
119 le: Annotated[
120 Optional[float],
121 Doc(
122 """
123 Less than or equal. If set, value must be less than or equal to this.
124 Only applicable to numbers.
125 """
126 ),
127 ] = None,
128 min_length: Annotated[
129 Optional[int],
130 Doc(
131 """
132 Minimum length for strings.
133 """
134 ),
135 ] = None,
136 max_length: Annotated[
137 Optional[int],
138 Doc(
139 """
140 Maximum length for strings.
141 """
142 ),
143 ] = None,
144 pattern: Annotated[
145 Optional[str],
146 Doc(
147 """
148 RegEx pattern for strings.
149 """
150 ),
151 ] = None,
152 regex: Annotated[
153 Optional[str],
154 Doc(
155 """
156 RegEx pattern for strings.
157 """
158 ),
159 deprecated(
160 "Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
161 ),
162 ] = None,
163 discriminator: Annotated[
164 Union[str, None],
165 Doc(
166 """
167 Parameter field name for discriminating the type in a tagged union.
168 """
169 ),
170 ] = None,
171 strict: Annotated[
172 Union[bool, None],
173 Doc(
174 """
175 If `True`, strict validation is applied to the field.
176 """
177 ),
178 ] = _Unset,
179 multiple_of: Annotated[
180 Union[float, None],
181 Doc(
182 """
183 Value must be a multiple of this. Only applicable to numbers.
184 """
185 ),
186 ] = _Unset,
187 allow_inf_nan: Annotated[
188 Union[bool, None],
189 Doc(
190 """
191 Allow `inf`, `-inf`, `nan`. Only applicable to numbers.
192 """
193 ),
194 ] = _Unset,
195 max_digits: Annotated[
196 Union[int, None],
197 Doc(
198 """
199 Maximum number of allow digits for strings.
200 """
201 ),
202 ] = _Unset,
203 decimal_places: Annotated[
204 Union[int, None],
205 Doc(
206 """
207 Maximum number of decimal places allowed for numbers.
208 """
209 ),
210 ] = _Unset,
211 examples: Annotated[
212 Optional[List[Any]],
213 Doc(
214 """
215 Example values for this field.
216 """
217 ),
218 ] = None,
219 example: Annotated[
220 Optional[Any],
221 deprecated(
222 "Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
223 "although still supported. Use examples instead."
224 ),
225 ] = _Unset,
226 openapi_examples: Annotated[
227 Optional[Dict[str, Example]],
228 Doc(
229 """
230 OpenAPI-specific examples.
232 It will be added to the generated OpenAPI (e.g. visible at `/docs`).
234 Swagger UI (that provides the `/docs` interface) has better support for the
235 OpenAPI-specific examples than the JSON Schema `examples`, that's the main
236 use case for this.
238 Read more about it in the
239 [FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/#using-the-openapi_examples-parameter).
240 """
241 ),
242 ] = None,
243 deprecated: Annotated[
244 Union[deprecated, str, bool, None],
245 Doc(
246 """
247 Mark this parameter field as deprecated.
249 It will affect the generated OpenAPI (e.g. visible at `/docs`).
250 """
251 ),
252 ] = None,
253 include_in_schema: Annotated[
254 bool,
255 Doc(
256 """
257 To include (or not) this parameter field in the generated OpenAPI.
258 You probably don't need it, but it's available.
260 This affects the generated OpenAPI (e.g. visible at `/docs`).
261 """
262 ),
263 ] = True,
264 json_schema_extra: Annotated[
265 Union[Dict[str, Any], None],
266 Doc(
267 """
268 Any additional JSON schema data.
269 """
270 ),
271 ] = None,
272 **extra: Annotated[
273 Any,
274 Doc(
275 """
276 Include extra fields used by the JSON Schema.
277 """
278 ),
279 deprecated(
280 """
281 The `extra` kwargs is deprecated. Use `json_schema_extra` instead.
282 """
283 ),
284 ],
285) -> Any:
286 """
287 Declare a path parameter for a *path operation*.
289 Read more about it in the
290 [FastAPI docs for Path Parameters and Numeric Validations](https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/).
292 ```python
293 from typing import Annotated
295 from fastapi import FastAPI, Path
297 app = FastAPI()
300 @app.get("/items/{item_id}")
301 async def read_items(
302 item_id: Annotated[int, Path(title="The ID of the item to get")],
303 ):
304 return {"item_id": item_id}
305 ```
306 """
307 return params.Path( 1avhibwjkcxlmdynoezpqfArsgBtu
308 default=default,
309 default_factory=default_factory,
310 alias=alias,
311 alias_priority=alias_priority,
312 validation_alias=validation_alias,
313 serialization_alias=serialization_alias,
314 title=title,
315 description=description,
316 gt=gt,
317 ge=ge,
318 lt=lt,
319 le=le,
320 min_length=min_length,
321 max_length=max_length,
322 pattern=pattern,
323 regex=regex,
324 discriminator=discriminator,
325 strict=strict,
326 multiple_of=multiple_of,
327 allow_inf_nan=allow_inf_nan,
328 max_digits=max_digits,
329 decimal_places=decimal_places,
330 example=example,
331 examples=examples,
332 openapi_examples=openapi_examples,
333 deprecated=deprecated,
334 include_in_schema=include_in_schema,
335 json_schema_extra=json_schema_extra,
336 **extra,
337 )
340def Query( # noqa: N802 1abcdefg
341 default: Annotated[
342 Any,
343 Doc(
344 """
345 Default value if the parameter field is not set.
346 """
347 ),
348 ] = Undefined,
349 *,
350 default_factory: Annotated[
351 Union[Callable[[], Any], None],
352 Doc(
353 """
354 A callable to generate the default value.
356 This doesn't affect `Path` parameters as the value is always required.
357 The parameter is available only for compatibility.
358 """
359 ),
360 ] = _Unset,
361 alias: Annotated[
362 Optional[str],
363 Doc(
364 """
365 An alternative name for the parameter field.
367 This will be used to extract the data and for the generated OpenAPI.
368 It is particularly useful when you can't use the name you want because it
369 is a Python reserved keyword or similar.
370 """
371 ),
372 ] = None,
373 alias_priority: Annotated[
374 Union[int, None],
375 Doc(
376 """
377 Priority of the alias. This affects whether an alias generator is used.
378 """
379 ),
380 ] = _Unset,
381 # TODO: update when deprecating Pydantic v1, import these types
382 # validation_alias: str | AliasPath | AliasChoices | None
383 validation_alias: Annotated[
384 Union[str, None],
385 Doc(
386 """
387 'Whitelist' validation step. The parameter field will be the single one
388 allowed by the alias or set of aliases defined.
389 """
390 ),
391 ] = None,
392 serialization_alias: Annotated[
393 Union[str, None],
394 Doc(
395 """
396 'Blacklist' validation step. The vanilla parameter field will be the
397 single one of the alias' or set of aliases' fields and all the other
398 fields will be ignored at serialization time.
399 """
400 ),
401 ] = None,
402 title: Annotated[
403 Optional[str],
404 Doc(
405 """
406 Human-readable title.
407 """
408 ),
409 ] = None,
410 description: Annotated[
411 Optional[str],
412 Doc(
413 """
414 Human-readable description.
415 """
416 ),
417 ] = None,
418 gt: Annotated[
419 Optional[float],
420 Doc(
421 """
422 Greater than. If set, value must be greater than this. Only applicable to
423 numbers.
424 """
425 ),
426 ] = None,
427 ge: Annotated[
428 Optional[float],
429 Doc(
430 """
431 Greater than or equal. If set, value must be greater than or equal to
432 this. Only applicable to numbers.
433 """
434 ),
435 ] = None,
436 lt: Annotated[
437 Optional[float],
438 Doc(
439 """
440 Less than. If set, value must be less than this. Only applicable to numbers.
441 """
442 ),
443 ] = None,
444 le: Annotated[
445 Optional[float],
446 Doc(
447 """
448 Less than or equal. If set, value must be less than or equal to this.
449 Only applicable to numbers.
450 """
451 ),
452 ] = None,
453 min_length: Annotated[
454 Optional[int],
455 Doc(
456 """
457 Minimum length for strings.
458 """
459 ),
460 ] = None,
461 max_length: Annotated[
462 Optional[int],
463 Doc(
464 """
465 Maximum length for strings.
466 """
467 ),
468 ] = None,
469 pattern: Annotated[
470 Optional[str],
471 Doc(
472 """
473 RegEx pattern for strings.
474 """
475 ),
476 ] = None,
477 regex: Annotated[
478 Optional[str],
479 Doc(
480 """
481 RegEx pattern for strings.
482 """
483 ),
484 deprecated(
485 "Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
486 ),
487 ] = None,
488 discriminator: Annotated[
489 Union[str, None],
490 Doc(
491 """
492 Parameter field name for discriminating the type in a tagged union.
493 """
494 ),
495 ] = None,
496 strict: Annotated[
497 Union[bool, None],
498 Doc(
499 """
500 If `True`, strict validation is applied to the field.
501 """
502 ),
503 ] = _Unset,
504 multiple_of: Annotated[
505 Union[float, None],
506 Doc(
507 """
508 Value must be a multiple of this. Only applicable to numbers.
509 """
510 ),
511 ] = _Unset,
512 allow_inf_nan: Annotated[
513 Union[bool, None],
514 Doc(
515 """
516 Allow `inf`, `-inf`, `nan`. Only applicable to numbers.
517 """
518 ),
519 ] = _Unset,
520 max_digits: Annotated[
521 Union[int, None],
522 Doc(
523 """
524 Maximum number of allow digits for strings.
525 """
526 ),
527 ] = _Unset,
528 decimal_places: Annotated[
529 Union[int, None],
530 Doc(
531 """
532 Maximum number of decimal places allowed for numbers.
533 """
534 ),
535 ] = _Unset,
536 examples: Annotated[
537 Optional[List[Any]],
538 Doc(
539 """
540 Example values for this field.
541 """
542 ),
543 ] = None,
544 example: Annotated[
545 Optional[Any],
546 deprecated(
547 "Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
548 "although still supported. Use examples instead."
549 ),
550 ] = _Unset,
551 openapi_examples: Annotated[
552 Optional[Dict[str, Example]],
553 Doc(
554 """
555 OpenAPI-specific examples.
557 It will be added to the generated OpenAPI (e.g. visible at `/docs`).
559 Swagger UI (that provides the `/docs` interface) has better support for the
560 OpenAPI-specific examples than the JSON Schema `examples`, that's the main
561 use case for this.
563 Read more about it in the
564 [FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/#using-the-openapi_examples-parameter).
565 """
566 ),
567 ] = None,
568 deprecated: Annotated[
569 Union[deprecated, str, bool, None],
570 Doc(
571 """
572 Mark this parameter field as deprecated.
574 It will affect the generated OpenAPI (e.g. visible at `/docs`).
575 """
576 ),
577 ] = None,
578 include_in_schema: Annotated[
579 bool,
580 Doc(
581 """
582 To include (or not) this parameter field in the generated OpenAPI.
583 You probably don't need it, but it's available.
585 This affects the generated OpenAPI (e.g. visible at `/docs`).
586 """
587 ),
588 ] = True,
589 json_schema_extra: Annotated[
590 Union[Dict[str, Any], None],
591 Doc(
592 """
593 Any additional JSON schema data.
594 """
595 ),
596 ] = None,
597 **extra: Annotated[
598 Any,
599 Doc(
600 """
601 Include extra fields used by the JSON Schema.
602 """
603 ),
604 deprecated(
605 """
606 The `extra` kwargs is deprecated. Use `json_schema_extra` instead.
607 """
608 ),
609 ],
610) -> Any:
611 return params.Query( 2a C v 4 5 6 7 8 9 h i b D w ! # $ % ' ( j k c E x ) * + , - . / : ; = l m d F y ? @ [ ] ^ _ ` { | } n o e G z ~ abbbcbdbebfbgbhbibp q f H A jbkblbmbnbobpbqbrbsbr s g I B tbubvbwbxbybzbAbBbCbt u
612 default=default,
613 default_factory=default_factory,
614 alias=alias,
615 alias_priority=alias_priority,
616 validation_alias=validation_alias,
617 serialization_alias=serialization_alias,
618 title=title,
619 description=description,
620 gt=gt,
621 ge=ge,
622 lt=lt,
623 le=le,
624 min_length=min_length,
625 max_length=max_length,
626 pattern=pattern,
627 regex=regex,
628 discriminator=discriminator,
629 strict=strict,
630 multiple_of=multiple_of,
631 allow_inf_nan=allow_inf_nan,
632 max_digits=max_digits,
633 decimal_places=decimal_places,
634 example=example,
635 examples=examples,
636 openapi_examples=openapi_examples,
637 deprecated=deprecated,
638 include_in_schema=include_in_schema,
639 json_schema_extra=json_schema_extra,
640 **extra,
641 )
644def Header( # noqa: N802 1abcdefg
645 default: Annotated[
646 Any,
647 Doc(
648 """
649 Default value if the parameter field is not set.
650 """
651 ),
652 ] = Undefined,
653 *,
654 default_factory: Annotated[
655 Union[Callable[[], Any], None],
656 Doc(
657 """
658 A callable to generate the default value.
660 This doesn't affect `Path` parameters as the value is always required.
661 The parameter is available only for compatibility.
662 """
663 ),
664 ] = _Unset,
665 alias: Annotated[
666 Optional[str],
667 Doc(
668 """
669 An alternative name for the parameter field.
671 This will be used to extract the data and for the generated OpenAPI.
672 It is particularly useful when you can't use the name you want because it
673 is a Python reserved keyword or similar.
674 """
675 ),
676 ] = None,
677 alias_priority: Annotated[
678 Union[int, None],
679 Doc(
680 """
681 Priority of the alias. This affects whether an alias generator is used.
682 """
683 ),
684 ] = _Unset,
685 # TODO: update when deprecating Pydantic v1, import these types
686 # validation_alias: str | AliasPath | AliasChoices | None
687 validation_alias: Annotated[
688 Union[str, None],
689 Doc(
690 """
691 'Whitelist' validation step. The parameter field will be the single one
692 allowed by the alias or set of aliases defined.
693 """
694 ),
695 ] = None,
696 serialization_alias: Annotated[
697 Union[str, None],
698 Doc(
699 """
700 'Blacklist' validation step. The vanilla parameter field will be the
701 single one of the alias' or set of aliases' fields and all the other
702 fields will be ignored at serialization time.
703 """
704 ),
705 ] = None,
706 convert_underscores: Annotated[
707 bool,
708 Doc(
709 """
710 Automatically convert underscores to hyphens in the parameter field name.
712 Read more about it in the
713 [FastAPI docs for Header Parameters](https://fastapi.tiangolo.com/tutorial/header-params/#automatic-conversion)
714 """
715 ),
716 ] = True,
717 title: Annotated[
718 Optional[str],
719 Doc(
720 """
721 Human-readable title.
722 """
723 ),
724 ] = None,
725 description: Annotated[
726 Optional[str],
727 Doc(
728 """
729 Human-readable description.
730 """
731 ),
732 ] = None,
733 gt: Annotated[
734 Optional[float],
735 Doc(
736 """
737 Greater than. If set, value must be greater than this. Only applicable to
738 numbers.
739 """
740 ),
741 ] = None,
742 ge: Annotated[
743 Optional[float],
744 Doc(
745 """
746 Greater than or equal. If set, value must be greater than or equal to
747 this. Only applicable to numbers.
748 """
749 ),
750 ] = None,
751 lt: Annotated[
752 Optional[float],
753 Doc(
754 """
755 Less than. If set, value must be less than this. Only applicable to numbers.
756 """
757 ),
758 ] = None,
759 le: Annotated[
760 Optional[float],
761 Doc(
762 """
763 Less than or equal. If set, value must be less than or equal to this.
764 Only applicable to numbers.
765 """
766 ),
767 ] = None,
768 min_length: Annotated[
769 Optional[int],
770 Doc(
771 """
772 Minimum length for strings.
773 """
774 ),
775 ] = None,
776 max_length: Annotated[
777 Optional[int],
778 Doc(
779 """
780 Maximum length for strings.
781 """
782 ),
783 ] = None,
784 pattern: Annotated[
785 Optional[str],
786 Doc(
787 """
788 RegEx pattern for strings.
789 """
790 ),
791 ] = None,
792 regex: Annotated[
793 Optional[str],
794 Doc(
795 """
796 RegEx pattern for strings.
797 """
798 ),
799 deprecated(
800 "Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
801 ),
802 ] = None,
803 discriminator: Annotated[
804 Union[str, None],
805 Doc(
806 """
807 Parameter field name for discriminating the type in a tagged union.
808 """
809 ),
810 ] = None,
811 strict: Annotated[
812 Union[bool, None],
813 Doc(
814 """
815 If `True`, strict validation is applied to the field.
816 """
817 ),
818 ] = _Unset,
819 multiple_of: Annotated[
820 Union[float, None],
821 Doc(
822 """
823 Value must be a multiple of this. Only applicable to numbers.
824 """
825 ),
826 ] = _Unset,
827 allow_inf_nan: Annotated[
828 Union[bool, None],
829 Doc(
830 """
831 Allow `inf`, `-inf`, `nan`. Only applicable to numbers.
832 """
833 ),
834 ] = _Unset,
835 max_digits: Annotated[
836 Union[int, None],
837 Doc(
838 """
839 Maximum number of allow digits for strings.
840 """
841 ),
842 ] = _Unset,
843 decimal_places: Annotated[
844 Union[int, None],
845 Doc(
846 """
847 Maximum number of decimal places allowed for numbers.
848 """
849 ),
850 ] = _Unset,
851 examples: Annotated[
852 Optional[List[Any]],
853 Doc(
854 """
855 Example values for this field.
856 """
857 ),
858 ] = None,
859 example: Annotated[
860 Optional[Any],
861 deprecated(
862 "Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
863 "although still supported. Use examples instead."
864 ),
865 ] = _Unset,
866 openapi_examples: Annotated[
867 Optional[Dict[str, Example]],
868 Doc(
869 """
870 OpenAPI-specific examples.
872 It will be added to the generated OpenAPI (e.g. visible at `/docs`).
874 Swagger UI (that provides the `/docs` interface) has better support for the
875 OpenAPI-specific examples than the JSON Schema `examples`, that's the main
876 use case for this.
878 Read more about it in the
879 [FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/#using-the-openapi_examples-parameter).
880 """
881 ),
882 ] = None,
883 deprecated: Annotated[
884 Union[deprecated, str, bool, None],
885 Doc(
886 """
887 Mark this parameter field as deprecated.
889 It will affect the generated OpenAPI (e.g. visible at `/docs`).
890 """
891 ),
892 ] = None,
893 include_in_schema: Annotated[
894 bool,
895 Doc(
896 """
897 To include (or not) this parameter field in the generated OpenAPI.
898 You probably don't need it, but it's available.
900 This affects the generated OpenAPI (e.g. visible at `/docs`).
901 """
902 ),
903 ] = True,
904 json_schema_extra: Annotated[
905 Union[Dict[str, Any], None],
906 Doc(
907 """
908 Any additional JSON schema data.
909 """
910 ),
911 ] = None,
912 **extra: Annotated[
913 Any,
914 Doc(
915 """
916 Include extra fields used by the JSON Schema.
917 """
918 ),
919 deprecated(
920 """
921 The `extra` kwargs is deprecated. Use `json_schema_extra` instead.
922 """
923 ),
924 ],
925) -> Any:
926 return params.Header( 1ahibjkclmdnoepqfrsgtu
927 default=default,
928 default_factory=default_factory,
929 alias=alias,
930 alias_priority=alias_priority,
931 validation_alias=validation_alias,
932 serialization_alias=serialization_alias,
933 convert_underscores=convert_underscores,
934 title=title,
935 description=description,
936 gt=gt,
937 ge=ge,
938 lt=lt,
939 le=le,
940 min_length=min_length,
941 max_length=max_length,
942 pattern=pattern,
943 regex=regex,
944 discriminator=discriminator,
945 strict=strict,
946 multiple_of=multiple_of,
947 allow_inf_nan=allow_inf_nan,
948 max_digits=max_digits,
949 decimal_places=decimal_places,
950 example=example,
951 examples=examples,
952 openapi_examples=openapi_examples,
953 deprecated=deprecated,
954 include_in_schema=include_in_schema,
955 json_schema_extra=json_schema_extra,
956 **extra,
957 )
960def Cookie( # noqa: N802 1abcdefg
961 default: Annotated[
962 Any,
963 Doc(
964 """
965 Default value if the parameter field is not set.
966 """
967 ),
968 ] = Undefined,
969 *,
970 default_factory: Annotated[
971 Union[Callable[[], Any], None],
972 Doc(
973 """
974 A callable to generate the default value.
976 This doesn't affect `Path` parameters as the value is always required.
977 The parameter is available only for compatibility.
978 """
979 ),
980 ] = _Unset,
981 alias: Annotated[
982 Optional[str],
983 Doc(
984 """
985 An alternative name for the parameter field.
987 This will be used to extract the data and for the generated OpenAPI.
988 It is particularly useful when you can't use the name you want because it
989 is a Python reserved keyword or similar.
990 """
991 ),
992 ] = None,
993 alias_priority: Annotated[
994 Union[int, None],
995 Doc(
996 """
997 Priority of the alias. This affects whether an alias generator is used.
998 """
999 ),
1000 ] = _Unset,
1001 # TODO: update when deprecating Pydantic v1, import these types
1002 # validation_alias: str | AliasPath | AliasChoices | None
1003 validation_alias: Annotated[
1004 Union[str, None],
1005 Doc(
1006 """
1007 'Whitelist' validation step. The parameter field will be the single one
1008 allowed by the alias or set of aliases defined.
1009 """
1010 ),
1011 ] = None,
1012 serialization_alias: Annotated[
1013 Union[str, None],
1014 Doc(
1015 """
1016 'Blacklist' validation step. The vanilla parameter field will be the
1017 single one of the alias' or set of aliases' fields and all the other
1018 fields will be ignored at serialization time.
1019 """
1020 ),
1021 ] = None,
1022 title: Annotated[
1023 Optional[str],
1024 Doc(
1025 """
1026 Human-readable title.
1027 """
1028 ),
1029 ] = None,
1030 description: Annotated[
1031 Optional[str],
1032 Doc(
1033 """
1034 Human-readable description.
1035 """
1036 ),
1037 ] = None,
1038 gt: Annotated[
1039 Optional[float],
1040 Doc(
1041 """
1042 Greater than. If set, value must be greater than this. Only applicable to
1043 numbers.
1044 """
1045 ),
1046 ] = None,
1047 ge: Annotated[
1048 Optional[float],
1049 Doc(
1050 """
1051 Greater than or equal. If set, value must be greater than or equal to
1052 this. Only applicable to numbers.
1053 """
1054 ),
1055 ] = None,
1056 lt: Annotated[
1057 Optional[float],
1058 Doc(
1059 """
1060 Less than. If set, value must be less than this. Only applicable to numbers.
1061 """
1062 ),
1063 ] = None,
1064 le: Annotated[
1065 Optional[float],
1066 Doc(
1067 """
1068 Less than or equal. If set, value must be less than or equal to this.
1069 Only applicable to numbers.
1070 """
1071 ),
1072 ] = None,
1073 min_length: Annotated[
1074 Optional[int],
1075 Doc(
1076 """
1077 Minimum length for strings.
1078 """
1079 ),
1080 ] = None,
1081 max_length: Annotated[
1082 Optional[int],
1083 Doc(
1084 """
1085 Maximum length for strings.
1086 """
1087 ),
1088 ] = None,
1089 pattern: Annotated[
1090 Optional[str],
1091 Doc(
1092 """
1093 RegEx pattern for strings.
1094 """
1095 ),
1096 ] = None,
1097 regex: Annotated[
1098 Optional[str],
1099 Doc(
1100 """
1101 RegEx pattern for strings.
1102 """
1103 ),
1104 deprecated(
1105 "Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
1106 ),
1107 ] = None,
1108 discriminator: Annotated[
1109 Union[str, None],
1110 Doc(
1111 """
1112 Parameter field name for discriminating the type in a tagged union.
1113 """
1114 ),
1115 ] = None,
1116 strict: Annotated[
1117 Union[bool, None],
1118 Doc(
1119 """
1120 If `True`, strict validation is applied to the field.
1121 """
1122 ),
1123 ] = _Unset,
1124 multiple_of: Annotated[
1125 Union[float, None],
1126 Doc(
1127 """
1128 Value must be a multiple of this. Only applicable to numbers.
1129 """
1130 ),
1131 ] = _Unset,
1132 allow_inf_nan: Annotated[
1133 Union[bool, None],
1134 Doc(
1135 """
1136 Allow `inf`, `-inf`, `nan`. Only applicable to numbers.
1137 """
1138 ),
1139 ] = _Unset,
1140 max_digits: Annotated[
1141 Union[int, None],
1142 Doc(
1143 """
1144 Maximum number of allow digits for strings.
1145 """
1146 ),
1147 ] = _Unset,
1148 decimal_places: Annotated[
1149 Union[int, None],
1150 Doc(
1151 """
1152 Maximum number of decimal places allowed for numbers.
1153 """
1154 ),
1155 ] = _Unset,
1156 examples: Annotated[
1157 Optional[List[Any]],
1158 Doc(
1159 """
1160 Example values for this field.
1161 """
1162 ),
1163 ] = None,
1164 example: Annotated[
1165 Optional[Any],
1166 deprecated(
1167 "Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
1168 "although still supported. Use examples instead."
1169 ),
1170 ] = _Unset,
1171 openapi_examples: Annotated[
1172 Optional[Dict[str, Example]],
1173 Doc(
1174 """
1175 OpenAPI-specific examples.
1177 It will be added to the generated OpenAPI (e.g. visible at `/docs`).
1179 Swagger UI (that provides the `/docs` interface) has better support for the
1180 OpenAPI-specific examples than the JSON Schema `examples`, that's the main
1181 use case for this.
1183 Read more about it in the
1184 [FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/#using-the-openapi_examples-parameter).
1185 """
1186 ),
1187 ] = None,
1188 deprecated: Annotated[
1189 Union[deprecated, str, bool, None],
1190 Doc(
1191 """
1192 Mark this parameter field as deprecated.
1194 It will affect the generated OpenAPI (e.g. visible at `/docs`).
1195 """
1196 ),
1197 ] = None,
1198 include_in_schema: Annotated[
1199 bool,
1200 Doc(
1201 """
1202 To include (or not) this parameter field in the generated OpenAPI.
1203 You probably don't need it, but it's available.
1205 This affects the generated OpenAPI (e.g. visible at `/docs`).
1206 """
1207 ),
1208 ] = True,
1209 json_schema_extra: Annotated[
1210 Union[Dict[str, Any], None],
1211 Doc(
1212 """
1213 Any additional JSON schema data.
1214 """
1215 ),
1216 ] = None,
1217 **extra: Annotated[
1218 Any,
1219 Doc(
1220 """
1221 Include extra fields used by the JSON Schema.
1222 """
1223 ),
1224 deprecated(
1225 """
1226 The `extra` kwargs is deprecated. Use `json_schema_extra` instead.
1227 """
1228 ),
1229 ],
1230) -> Any:
1231 return params.Cookie( 1ahibjkclmdnoepqfrsgtu
1232 default=default,
1233 default_factory=default_factory,
1234 alias=alias,
1235 alias_priority=alias_priority,
1236 validation_alias=validation_alias,
1237 serialization_alias=serialization_alias,
1238 title=title,
1239 description=description,
1240 gt=gt,
1241 ge=ge,
1242 lt=lt,
1243 le=le,
1244 min_length=min_length,
1245 max_length=max_length,
1246 pattern=pattern,
1247 regex=regex,
1248 discriminator=discriminator,
1249 strict=strict,
1250 multiple_of=multiple_of,
1251 allow_inf_nan=allow_inf_nan,
1252 max_digits=max_digits,
1253 decimal_places=decimal_places,
1254 example=example,
1255 examples=examples,
1256 openapi_examples=openapi_examples,
1257 deprecated=deprecated,
1258 include_in_schema=include_in_schema,
1259 json_schema_extra=json_schema_extra,
1260 **extra,
1261 )
1264def Body( # noqa: N802 1abcdefg
1265 default: Annotated[
1266 Any,
1267 Doc(
1268 """
1269 Default value if the parameter field is not set.
1270 """
1271 ),
1272 ] = Undefined,
1273 *,
1274 default_factory: Annotated[
1275 Union[Callable[[], Any], None],
1276 Doc(
1277 """
1278 A callable to generate the default value.
1280 This doesn't affect `Path` parameters as the value is always required.
1281 The parameter is available only for compatibility.
1282 """
1283 ),
1284 ] = _Unset,
1285 embed: Annotated[
1286 Union[bool, None],
1287 Doc(
1288 """
1289 When `embed` is `True`, the parameter will be expected in a JSON body as a
1290 key instead of being the JSON body itself.
1292 This happens automatically when more than one `Body` parameter is declared.
1294 Read more about it in the
1295 [FastAPI docs for Body - Multiple Parameters](https://fastapi.tiangolo.com/tutorial/body-multiple-params/#embed-a-single-body-parameter).
1296 """
1297 ),
1298 ] = None,
1299 media_type: Annotated[
1300 str,
1301 Doc(
1302 """
1303 The media type of this parameter field. Changing it would affect the
1304 generated OpenAPI, but currently it doesn't affect the parsing of the data.
1305 """
1306 ),
1307 ] = "application/json",
1308 alias: Annotated[
1309 Optional[str],
1310 Doc(
1311 """
1312 An alternative name for the parameter field.
1314 This will be used to extract the data and for the generated OpenAPI.
1315 It is particularly useful when you can't use the name you want because it
1316 is a Python reserved keyword or similar.
1317 """
1318 ),
1319 ] = None,
1320 alias_priority: Annotated[
1321 Union[int, None],
1322 Doc(
1323 """
1324 Priority of the alias. This affects whether an alias generator is used.
1325 """
1326 ),
1327 ] = _Unset,
1328 # TODO: update when deprecating Pydantic v1, import these types
1329 # validation_alias: str | AliasPath | AliasChoices | None
1330 validation_alias: Annotated[
1331 Union[str, None],
1332 Doc(
1333 """
1334 'Whitelist' validation step. The parameter field will be the single one
1335 allowed by the alias or set of aliases defined.
1336 """
1337 ),
1338 ] = None,
1339 serialization_alias: Annotated[
1340 Union[str, None],
1341 Doc(
1342 """
1343 'Blacklist' validation step. The vanilla parameter field will be the
1344 single one of the alias' or set of aliases' fields and all the other
1345 fields will be ignored at serialization time.
1346 """
1347 ),
1348 ] = None,
1349 title: Annotated[
1350 Optional[str],
1351 Doc(
1352 """
1353 Human-readable title.
1354 """
1355 ),
1356 ] = None,
1357 description: Annotated[
1358 Optional[str],
1359 Doc(
1360 """
1361 Human-readable description.
1362 """
1363 ),
1364 ] = None,
1365 gt: Annotated[
1366 Optional[float],
1367 Doc(
1368 """
1369 Greater than. If set, value must be greater than this. Only applicable to
1370 numbers.
1371 """
1372 ),
1373 ] = None,
1374 ge: Annotated[
1375 Optional[float],
1376 Doc(
1377 """
1378 Greater than or equal. If set, value must be greater than or equal to
1379 this. Only applicable to numbers.
1380 """
1381 ),
1382 ] = None,
1383 lt: Annotated[
1384 Optional[float],
1385 Doc(
1386 """
1387 Less than. If set, value must be less than this. Only applicable to numbers.
1388 """
1389 ),
1390 ] = None,
1391 le: Annotated[
1392 Optional[float],
1393 Doc(
1394 """
1395 Less than or equal. If set, value must be less than or equal to this.
1396 Only applicable to numbers.
1397 """
1398 ),
1399 ] = None,
1400 min_length: Annotated[
1401 Optional[int],
1402 Doc(
1403 """
1404 Minimum length for strings.
1405 """
1406 ),
1407 ] = None,
1408 max_length: Annotated[
1409 Optional[int],
1410 Doc(
1411 """
1412 Maximum length for strings.
1413 """
1414 ),
1415 ] = None,
1416 pattern: Annotated[
1417 Optional[str],
1418 Doc(
1419 """
1420 RegEx pattern for strings.
1421 """
1422 ),
1423 ] = None,
1424 regex: Annotated[
1425 Optional[str],
1426 Doc(
1427 """
1428 RegEx pattern for strings.
1429 """
1430 ),
1431 deprecated(
1432 "Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
1433 ),
1434 ] = None,
1435 discriminator: Annotated[
1436 Union[str, None],
1437 Doc(
1438 """
1439 Parameter field name for discriminating the type in a tagged union.
1440 """
1441 ),
1442 ] = None,
1443 strict: Annotated[
1444 Union[bool, None],
1445 Doc(
1446 """
1447 If `True`, strict validation is applied to the field.
1448 """
1449 ),
1450 ] = _Unset,
1451 multiple_of: Annotated[
1452 Union[float, None],
1453 Doc(
1454 """
1455 Value must be a multiple of this. Only applicable to numbers.
1456 """
1457 ),
1458 ] = _Unset,
1459 allow_inf_nan: Annotated[
1460 Union[bool, None],
1461 Doc(
1462 """
1463 Allow `inf`, `-inf`, `nan`. Only applicable to numbers.
1464 """
1465 ),
1466 ] = _Unset,
1467 max_digits: Annotated[
1468 Union[int, None],
1469 Doc(
1470 """
1471 Maximum number of allow digits for strings.
1472 """
1473 ),
1474 ] = _Unset,
1475 decimal_places: Annotated[
1476 Union[int, None],
1477 Doc(
1478 """
1479 Maximum number of decimal places allowed for numbers.
1480 """
1481 ),
1482 ] = _Unset,
1483 examples: Annotated[
1484 Optional[List[Any]],
1485 Doc(
1486 """
1487 Example values for this field.
1488 """
1489 ),
1490 ] = None,
1491 example: Annotated[
1492 Optional[Any],
1493 deprecated(
1494 "Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
1495 "although still supported. Use examples instead."
1496 ),
1497 ] = _Unset,
1498 openapi_examples: Annotated[
1499 Optional[Dict[str, Example]],
1500 Doc(
1501 """
1502 OpenAPI-specific examples.
1504 It will be added to the generated OpenAPI (e.g. visible at `/docs`).
1506 Swagger UI (that provides the `/docs` interface) has better support for the
1507 OpenAPI-specific examples than the JSON Schema `examples`, that's the main
1508 use case for this.
1510 Read more about it in the
1511 [FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/#using-the-openapi_examples-parameter).
1512 """
1513 ),
1514 ] = None,
1515 deprecated: Annotated[
1516 Union[deprecated, str, bool, None],
1517 Doc(
1518 """
1519 Mark this parameter field as deprecated.
1521 It will affect the generated OpenAPI (e.g. visible at `/docs`).
1522 """
1523 ),
1524 ] = None,
1525 include_in_schema: Annotated[
1526 bool,
1527 Doc(
1528 """
1529 To include (or not) this parameter field in the generated OpenAPI.
1530 You probably don't need it, but it's available.
1532 This affects the generated OpenAPI (e.g. visible at `/docs`).
1533 """
1534 ),
1535 ] = True,
1536 json_schema_extra: Annotated[
1537 Union[Dict[str, Any], None],
1538 Doc(
1539 """
1540 Any additional JSON schema data.
1541 """
1542 ),
1543 ] = None,
1544 **extra: Annotated[
1545 Any,
1546 Doc(
1547 """
1548 Include extra fields used by the JSON Schema.
1549 """
1550 ),
1551 deprecated(
1552 """
1553 The `extra` kwargs is deprecated. Use `json_schema_extra` instead.
1554 """
1555 ),
1556 ],
1557) -> Any:
1558 return params.Body( 1ahibjkclmdnoepqfrsgtu
1559 default=default,
1560 default_factory=default_factory,
1561 embed=embed,
1562 media_type=media_type,
1563 alias=alias,
1564 alias_priority=alias_priority,
1565 validation_alias=validation_alias,
1566 serialization_alias=serialization_alias,
1567 title=title,
1568 description=description,
1569 gt=gt,
1570 ge=ge,
1571 lt=lt,
1572 le=le,
1573 min_length=min_length,
1574 max_length=max_length,
1575 pattern=pattern,
1576 regex=regex,
1577 discriminator=discriminator,
1578 strict=strict,
1579 multiple_of=multiple_of,
1580 allow_inf_nan=allow_inf_nan,
1581 max_digits=max_digits,
1582 decimal_places=decimal_places,
1583 example=example,
1584 examples=examples,
1585 openapi_examples=openapi_examples,
1586 deprecated=deprecated,
1587 include_in_schema=include_in_schema,
1588 json_schema_extra=json_schema_extra,
1589 **extra,
1590 )
1593def Form( # noqa: N802 1abcdefg
1594 default: Annotated[
1595 Any,
1596 Doc(
1597 """
1598 Default value if the parameter field is not set.
1599 """
1600 ),
1601 ] = Undefined,
1602 *,
1603 default_factory: Annotated[
1604 Union[Callable[[], Any], None],
1605 Doc(
1606 """
1607 A callable to generate the default value.
1609 This doesn't affect `Path` parameters as the value is always required.
1610 The parameter is available only for compatibility.
1611 """
1612 ),
1613 ] = _Unset,
1614 media_type: Annotated[
1615 str,
1616 Doc(
1617 """
1618 The media type of this parameter field. Changing it would affect the
1619 generated OpenAPI, but currently it doesn't affect the parsing of the data.
1620 """
1621 ),
1622 ] = "application/x-www-form-urlencoded",
1623 alias: Annotated[
1624 Optional[str],
1625 Doc(
1626 """
1627 An alternative name for the parameter field.
1629 This will be used to extract the data and for the generated OpenAPI.
1630 It is particularly useful when you can't use the name you want because it
1631 is a Python reserved keyword or similar.
1632 """
1633 ),
1634 ] = None,
1635 alias_priority: Annotated[
1636 Union[int, None],
1637 Doc(
1638 """
1639 Priority of the alias. This affects whether an alias generator is used.
1640 """
1641 ),
1642 ] = _Unset,
1643 # TODO: update when deprecating Pydantic v1, import these types
1644 # validation_alias: str | AliasPath | AliasChoices | None
1645 validation_alias: Annotated[
1646 Union[str, None],
1647 Doc(
1648 """
1649 'Whitelist' validation step. The parameter field will be the single one
1650 allowed by the alias or set of aliases defined.
1651 """
1652 ),
1653 ] = None,
1654 serialization_alias: Annotated[
1655 Union[str, None],
1656 Doc(
1657 """
1658 'Blacklist' validation step. The vanilla parameter field will be the
1659 single one of the alias' or set of aliases' fields and all the other
1660 fields will be ignored at serialization time.
1661 """
1662 ),
1663 ] = None,
1664 title: Annotated[
1665 Optional[str],
1666 Doc(
1667 """
1668 Human-readable title.
1669 """
1670 ),
1671 ] = None,
1672 description: Annotated[
1673 Optional[str],
1674 Doc(
1675 """
1676 Human-readable description.
1677 """
1678 ),
1679 ] = None,
1680 gt: Annotated[
1681 Optional[float],
1682 Doc(
1683 """
1684 Greater than. If set, value must be greater than this. Only applicable to
1685 numbers.
1686 """
1687 ),
1688 ] = None,
1689 ge: Annotated[
1690 Optional[float],
1691 Doc(
1692 """
1693 Greater than or equal. If set, value must be greater than or equal to
1694 this. Only applicable to numbers.
1695 """
1696 ),
1697 ] = None,
1698 lt: Annotated[
1699 Optional[float],
1700 Doc(
1701 """
1702 Less than. If set, value must be less than this. Only applicable to numbers.
1703 """
1704 ),
1705 ] = None,
1706 le: Annotated[
1707 Optional[float],
1708 Doc(
1709 """
1710 Less than or equal. If set, value must be less than or equal to this.
1711 Only applicable to numbers.
1712 """
1713 ),
1714 ] = None,
1715 min_length: Annotated[
1716 Optional[int],
1717 Doc(
1718 """
1719 Minimum length for strings.
1720 """
1721 ),
1722 ] = None,
1723 max_length: Annotated[
1724 Optional[int],
1725 Doc(
1726 """
1727 Maximum length for strings.
1728 """
1729 ),
1730 ] = None,
1731 pattern: Annotated[
1732 Optional[str],
1733 Doc(
1734 """
1735 RegEx pattern for strings.
1736 """
1737 ),
1738 ] = None,
1739 regex: Annotated[
1740 Optional[str],
1741 Doc(
1742 """
1743 RegEx pattern for strings.
1744 """
1745 ),
1746 deprecated(
1747 "Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
1748 ),
1749 ] = None,
1750 discriminator: Annotated[
1751 Union[str, None],
1752 Doc(
1753 """
1754 Parameter field name for discriminating the type in a tagged union.
1755 """
1756 ),
1757 ] = None,
1758 strict: Annotated[
1759 Union[bool, None],
1760 Doc(
1761 """
1762 If `True`, strict validation is applied to the field.
1763 """
1764 ),
1765 ] = _Unset,
1766 multiple_of: Annotated[
1767 Union[float, None],
1768 Doc(
1769 """
1770 Value must be a multiple of this. Only applicable to numbers.
1771 """
1772 ),
1773 ] = _Unset,
1774 allow_inf_nan: Annotated[
1775 Union[bool, None],
1776 Doc(
1777 """
1778 Allow `inf`, `-inf`, `nan`. Only applicable to numbers.
1779 """
1780 ),
1781 ] = _Unset,
1782 max_digits: Annotated[
1783 Union[int, None],
1784 Doc(
1785 """
1786 Maximum number of allow digits for strings.
1787 """
1788 ),
1789 ] = _Unset,
1790 decimal_places: Annotated[
1791 Union[int, None],
1792 Doc(
1793 """
1794 Maximum number of decimal places allowed for numbers.
1795 """
1796 ),
1797 ] = _Unset,
1798 examples: Annotated[
1799 Optional[List[Any]],
1800 Doc(
1801 """
1802 Example values for this field.
1803 """
1804 ),
1805 ] = None,
1806 example: Annotated[
1807 Optional[Any],
1808 deprecated(
1809 "Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
1810 "although still supported. Use examples instead."
1811 ),
1812 ] = _Unset,
1813 openapi_examples: Annotated[
1814 Optional[Dict[str, Example]],
1815 Doc(
1816 """
1817 OpenAPI-specific examples.
1819 It will be added to the generated OpenAPI (e.g. visible at `/docs`).
1821 Swagger UI (that provides the `/docs` interface) has better support for the
1822 OpenAPI-specific examples than the JSON Schema `examples`, that's the main
1823 use case for this.
1825 Read more about it in the
1826 [FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/#using-the-openapi_examples-parameter).
1827 """
1828 ),
1829 ] = None,
1830 deprecated: Annotated[
1831 Union[deprecated, str, bool, None],
1832 Doc(
1833 """
1834 Mark this parameter field as deprecated.
1836 It will affect the generated OpenAPI (e.g. visible at `/docs`).
1837 """
1838 ),
1839 ] = None,
1840 include_in_schema: Annotated[
1841 bool,
1842 Doc(
1843 """
1844 To include (or not) this parameter field in the generated OpenAPI.
1845 You probably don't need it, but it's available.
1847 This affects the generated OpenAPI (e.g. visible at `/docs`).
1848 """
1849 ),
1850 ] = True,
1851 json_schema_extra: Annotated[
1852 Union[Dict[str, Any], None],
1853 Doc(
1854 """
1855 Any additional JSON schema data.
1856 """
1857 ),
1858 ] = None,
1859 **extra: Annotated[
1860 Any,
1861 Doc(
1862 """
1863 Include extra fields used by the JSON Schema.
1864 """
1865 ),
1866 deprecated(
1867 """
1868 The `extra` kwargs is deprecated. Use `json_schema_extra` instead.
1869 """
1870 ),
1871 ],
1872) -> Any:
1873 return params.Form( 2a DbJ EbFbK GbHbb IbL JbKbM LbMbc NbN ObPbO QbRbSbTbUbVbd WbP XbYbQ Zb0b1b2b3b4be 5bR 6b7bS 8b9b!b#b$b%bf 'bT (b)bU *b+b,b-b.b/bg :bV ;b=bW ?b@b[b]b^b_b
1874 default=default,
1875 default_factory=default_factory,
1876 media_type=media_type,
1877 alias=alias,
1878 alias_priority=alias_priority,
1879 validation_alias=validation_alias,
1880 serialization_alias=serialization_alias,
1881 title=title,
1882 description=description,
1883 gt=gt,
1884 ge=ge,
1885 lt=lt,
1886 le=le,
1887 min_length=min_length,
1888 max_length=max_length,
1889 pattern=pattern,
1890 regex=regex,
1891 discriminator=discriminator,
1892 strict=strict,
1893 multiple_of=multiple_of,
1894 allow_inf_nan=allow_inf_nan,
1895 max_digits=max_digits,
1896 decimal_places=decimal_places,
1897 example=example,
1898 examples=examples,
1899 openapi_examples=openapi_examples,
1900 deprecated=deprecated,
1901 include_in_schema=include_in_schema,
1902 json_schema_extra=json_schema_extra,
1903 **extra,
1904 )
1907def File( # noqa: N802 1abcdefg
1908 default: Annotated[
1909 Any,
1910 Doc(
1911 """
1912 Default value if the parameter field is not set.
1913 """
1914 ),
1915 ] = Undefined,
1916 *,
1917 default_factory: Annotated[
1918 Union[Callable[[], Any], None],
1919 Doc(
1920 """
1921 A callable to generate the default value.
1923 This doesn't affect `Path` parameters as the value is always required.
1924 The parameter is available only for compatibility.
1925 """
1926 ),
1927 ] = _Unset,
1928 media_type: Annotated[
1929 str,
1930 Doc(
1931 """
1932 The media type of this parameter field. Changing it would affect the
1933 generated OpenAPI, but currently it doesn't affect the parsing of the data.
1934 """
1935 ),
1936 ] = "multipart/form-data",
1937 alias: Annotated[
1938 Optional[str],
1939 Doc(
1940 """
1941 An alternative name for the parameter field.
1943 This will be used to extract the data and for the generated OpenAPI.
1944 It is particularly useful when you can't use the name you want because it
1945 is a Python reserved keyword or similar.
1946 """
1947 ),
1948 ] = None,
1949 alias_priority: Annotated[
1950 Union[int, None],
1951 Doc(
1952 """
1953 Priority of the alias. This affects whether an alias generator is used.
1954 """
1955 ),
1956 ] = _Unset,
1957 # TODO: update when deprecating Pydantic v1, import these types
1958 # validation_alias: str | AliasPath | AliasChoices | None
1959 validation_alias: Annotated[
1960 Union[str, None],
1961 Doc(
1962 """
1963 'Whitelist' validation step. The parameter field will be the single one
1964 allowed by the alias or set of aliases defined.
1965 """
1966 ),
1967 ] = None,
1968 serialization_alias: Annotated[
1969 Union[str, None],
1970 Doc(
1971 """
1972 'Blacklist' validation step. The vanilla parameter field will be the
1973 single one of the alias' or set of aliases' fields and all the other
1974 fields will be ignored at serialization time.
1975 """
1976 ),
1977 ] = None,
1978 title: Annotated[
1979 Optional[str],
1980 Doc(
1981 """
1982 Human-readable title.
1983 """
1984 ),
1985 ] = None,
1986 description: Annotated[
1987 Optional[str],
1988 Doc(
1989 """
1990 Human-readable description.
1991 """
1992 ),
1993 ] = None,
1994 gt: Annotated[
1995 Optional[float],
1996 Doc(
1997 """
1998 Greater than. If set, value must be greater than this. Only applicable to
1999 numbers.
2000 """
2001 ),
2002 ] = None,
2003 ge: Annotated[
2004 Optional[float],
2005 Doc(
2006 """
2007 Greater than or equal. If set, value must be greater than or equal to
2008 this. Only applicable to numbers.
2009 """
2010 ),
2011 ] = None,
2012 lt: Annotated[
2013 Optional[float],
2014 Doc(
2015 """
2016 Less than. If set, value must be less than this. Only applicable to numbers.
2017 """
2018 ),
2019 ] = None,
2020 le: Annotated[
2021 Optional[float],
2022 Doc(
2023 """
2024 Less than or equal. If set, value must be less than or equal to this.
2025 Only applicable to numbers.
2026 """
2027 ),
2028 ] = None,
2029 min_length: Annotated[
2030 Optional[int],
2031 Doc(
2032 """
2033 Minimum length for strings.
2034 """
2035 ),
2036 ] = None,
2037 max_length: Annotated[
2038 Optional[int],
2039 Doc(
2040 """
2041 Maximum length for strings.
2042 """
2043 ),
2044 ] = None,
2045 pattern: Annotated[
2046 Optional[str],
2047 Doc(
2048 """
2049 RegEx pattern for strings.
2050 """
2051 ),
2052 ] = None,
2053 regex: Annotated[
2054 Optional[str],
2055 Doc(
2056 """
2057 RegEx pattern for strings.
2058 """
2059 ),
2060 deprecated(
2061 "Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
2062 ),
2063 ] = None,
2064 discriminator: Annotated[
2065 Union[str, None],
2066 Doc(
2067 """
2068 Parameter field name for discriminating the type in a tagged union.
2069 """
2070 ),
2071 ] = None,
2072 strict: Annotated[
2073 Union[bool, None],
2074 Doc(
2075 """
2076 If `True`, strict validation is applied to the field.
2077 """
2078 ),
2079 ] = _Unset,
2080 multiple_of: Annotated[
2081 Union[float, None],
2082 Doc(
2083 """
2084 Value must be a multiple of this. Only applicable to numbers.
2085 """
2086 ),
2087 ] = _Unset,
2088 allow_inf_nan: Annotated[
2089 Union[bool, None],
2090 Doc(
2091 """
2092 Allow `inf`, `-inf`, `nan`. Only applicable to numbers.
2093 """
2094 ),
2095 ] = _Unset,
2096 max_digits: Annotated[
2097 Union[int, None],
2098 Doc(
2099 """
2100 Maximum number of allow digits for strings.
2101 """
2102 ),
2103 ] = _Unset,
2104 decimal_places: Annotated[
2105 Union[int, None],
2106 Doc(
2107 """
2108 Maximum number of decimal places allowed for numbers.
2109 """
2110 ),
2111 ] = _Unset,
2112 examples: Annotated[
2113 Optional[List[Any]],
2114 Doc(
2115 """
2116 Example values for this field.
2117 """
2118 ),
2119 ] = None,
2120 example: Annotated[
2121 Optional[Any],
2122 deprecated(
2123 "Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
2124 "although still supported. Use examples instead."
2125 ),
2126 ] = _Unset,
2127 openapi_examples: Annotated[
2128 Optional[Dict[str, Example]],
2129 Doc(
2130 """
2131 OpenAPI-specific examples.
2133 It will be added to the generated OpenAPI (e.g. visible at `/docs`).
2135 Swagger UI (that provides the `/docs` interface) has better support for the
2136 OpenAPI-specific examples than the JSON Schema `examples`, that's the main
2137 use case for this.
2139 Read more about it in the
2140 [FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/#using-the-openapi_examples-parameter).
2141 """
2142 ),
2143 ] = None,
2144 deprecated: Annotated[
2145 Union[deprecated, str, bool, None],
2146 Doc(
2147 """
2148 Mark this parameter field as deprecated.
2150 It will affect the generated OpenAPI (e.g. visible at `/docs`).
2151 """
2152 ),
2153 ] = None,
2154 include_in_schema: Annotated[
2155 bool,
2156 Doc(
2157 """
2158 To include (or not) this parameter field in the generated OpenAPI.
2159 You probably don't need it, but it's available.
2161 This affects the generated OpenAPI (e.g. visible at `/docs`).
2162 """
2163 ),
2164 ] = True,
2165 json_schema_extra: Annotated[
2166 Union[Dict[str, Any], None],
2167 Doc(
2168 """
2169 Any additional JSON schema data.
2170 """
2171 ),
2172 ] = None,
2173 **extra: Annotated[
2174 Any,
2175 Doc(
2176 """
2177 Include extra fields used by the JSON Schema.
2178 """
2179 ),
2180 deprecated(
2181 """
2182 The `extra` kwargs is deprecated. Use `json_schema_extra` instead.
2183 """
2184 ),
2185 ],
2186) -> Any:
2187 return params.File( 2a `b{bJ |b}bK b ~bacL bcccM c dcecN fcgcO d hcicP jckcQ e lcmcR ncocS f pcqcT rcscU g tcucV vcwcW
2188 default=default,
2189 default_factory=default_factory,
2190 media_type=media_type,
2191 alias=alias,
2192 alias_priority=alias_priority,
2193 validation_alias=validation_alias,
2194 serialization_alias=serialization_alias,
2195 title=title,
2196 description=description,
2197 gt=gt,
2198 ge=ge,
2199 lt=lt,
2200 le=le,
2201 min_length=min_length,
2202 max_length=max_length,
2203 pattern=pattern,
2204 regex=regex,
2205 discriminator=discriminator,
2206 strict=strict,
2207 multiple_of=multiple_of,
2208 allow_inf_nan=allow_inf_nan,
2209 max_digits=max_digits,
2210 decimal_places=decimal_places,
2211 example=example,
2212 examples=examples,
2213 openapi_examples=openapi_examples,
2214 deprecated=deprecated,
2215 include_in_schema=include_in_schema,
2216 json_schema_extra=json_schema_extra,
2217 **extra,
2218 )
2221def Depends( # noqa: N802 1abcdefg
2222 dependency: Annotated[
2223 Optional[Callable[..., Any]],
2224 Doc(
2225 """
2226 A "dependable" callable (like a function).
2228 Don't call it directly, FastAPI will call it for you, just pass the object
2229 directly.
2230 """
2231 ),
2232 ] = None,
2233 *,
2234 use_cache: Annotated[
2235 bool,
2236 Doc(
2237 """
2238 By default, after a dependency is called the first time in a request, if
2239 the dependency is declared again for the rest of the request (for example
2240 if the dependency is needed by several dependencies), the value will be
2241 re-used for the rest of the request.
2243 Set `use_cache` to `False` to disable this behavior and ensure the
2244 dependency is called again (if declared more than once) in the same request.
2245 """
2246 ),
2247 ] = True,
2248 scope: Annotated[
2249 Union[Literal["function", "request"], None],
2250 Doc(
2251 """
2252 Mainly for dependencies with `yield`, define when the dependency function
2253 should start (the code before `yield`) and when it should end (the code
2254 after `yield`).
2256 * `"function"`: start the dependency before the *path operation function*
2257 that handles the request, end the dependency after the *path operation
2258 function* ends, but **before** the response is sent back to the client.
2259 So, the dependency function will be executed **around** the *path operation
2260 **function***.
2261 * `"request"`: start the dependency before the *path operation function*
2262 that handles the request (similar to when using `"function"`), but end
2263 **after** the response is sent back to the client. So, the dependency
2264 function will be executed **around** the **request** and response cycle.
2265 """
2266 ),
2267 ] = None,
2268) -> Any:
2269 """
2270 Declare a FastAPI dependency.
2272 It takes a single "dependable" callable (like a function).
2274 Don't call it directly, FastAPI will call it for you.
2276 Read more about it in the
2277 [FastAPI docs for Dependencies](https://fastapi.tiangolo.com/tutorial/dependencies/).
2279 **Example**
2281 ```python
2282 from typing import Annotated
2284 from fastapi import Depends, FastAPI
2286 app = FastAPI()
2289 async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100):
2290 return {"q": q, "skip": skip, "limit": limit}
2293 @app.get("/items/")
2294 async def read_items(commons: Annotated[dict, Depends(common_parameters)]):
2295 return commons
2296 ```
2297 """
2298 return params.Depends(dependency=dependency, use_cache=use_cache, scope=scope) 2a C xcycX zcb D AcBcY Ccc E DcEcZ FcGcd F HcIc0 JcKce G LcMc1 NcOcf H PcQc2 RcScg I TcUc3 VcWc
2301def Security( # noqa: N802 1abcdefg
2302 dependency: Annotated[
2303 Optional[Callable[..., Any]],
2304 Doc(
2305 """
2306 A "dependable" callable (like a function).
2308 Don't call it directly, FastAPI will call it for you, just pass the object
2309 directly.
2310 """
2311 ),
2312 ] = None,
2313 *,
2314 scopes: Annotated[
2315 Optional[Sequence[str]],
2316 Doc(
2317 """
2318 OAuth2 scopes required for the *path operation* that uses this Security
2319 dependency.
2321 The term "scope" comes from the OAuth2 specification, it seems to be
2322 intentionally vague and interpretable. It normally refers to permissions,
2323 in cases to roles.
2325 These scopes are integrated with OpenAPI (and the API docs at `/docs`).
2326 So they are visible in the OpenAPI specification.
2327 )
2328 """
2329 ),
2330 ] = None,
2331 use_cache: Annotated[
2332 bool,
2333 Doc(
2334 """
2335 By default, after a dependency is called the first time in a request, if
2336 the dependency is declared again for the rest of the request (for example
2337 if the dependency is needed by several dependencies), the value will be
2338 re-used for the rest of the request.
2340 Set `use_cache` to `False` to disable this behavior and ensure the
2341 dependency is called again (if declared more than once) in the same request.
2342 """
2343 ),
2344 ] = True,
2345) -> Any:
2346 """
2347 Declare a FastAPI Security dependency.
2349 The only difference with a regular dependency is that it can declare OAuth2
2350 scopes that will be integrated with OpenAPI and the automatic UI docs (by default
2351 at `/docs`).
2353 It takes a single "dependable" callable (like a function).
2355 Don't call it directly, FastAPI will call it for you.
2357 Read more about it in the
2358 [FastAPI docs for Security](https://fastapi.tiangolo.com/tutorial/security/) and
2359 in the
2360 [FastAPI docs for OAuth2 scopes](https://fastapi.tiangolo.com/advanced/security/oauth2-scopes/).
2362 **Example**
2364 ```python
2365 from typing import Annotated
2367 from fastapi import Security, FastAPI
2369 from .db import User
2370 from .security import get_current_active_user
2372 app = FastAPI()
2374 @app.get("/users/me/items/")
2375 async def read_own_items(
2376 current_user: Annotated[User, Security(get_current_active_user, scopes=["items"])]
2377 ):
2378 return [{"item_id": "Foo", "owner": current_user.username}]
2379 ```
2380 """
2381 return params.Security(dependency=dependency, scopes=scopes, use_cache=use_cache) 1aXbYcZd0e1f2g3