fastapi 0.102.0__py3-none-any.whl → 0.103.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fastapi might be problematic. Click here for more details.

fastapi/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
2
2
 
3
- __version__ = "0.102.0"
3
+ __version__ = "0.103.0"
4
4
 
5
5
  from starlette import status as status
6
6
 
fastapi/openapi/models.py CHANGED
@@ -11,7 +11,7 @@ from fastapi._compat import (
11
11
  )
12
12
  from fastapi.logger import logger
13
13
  from pydantic import AnyUrl, BaseModel, Field
14
- from typing_extensions import Annotated, Literal
14
+ from typing_extensions import Annotated, Literal, TypedDict
15
15
  from typing_extensions import deprecated as typing_deprecated
16
16
 
17
17
  try:
@@ -267,14 +267,14 @@ class Schema(BaseModel):
267
267
  SchemaOrBool = Union[Schema, bool]
268
268
 
269
269
 
270
- class Example(BaseModel):
271
- summary: Optional[str] = None
272
- description: Optional[str] = None
273
- value: Optional[Any] = None
274
- externalValue: Optional[AnyUrl] = None
270
+ class Example(TypedDict, total=False):
271
+ summary: Optional[str]
272
+ description: Optional[str]
273
+ value: Optional[Any]
274
+ externalValue: Optional[AnyUrl]
275
275
 
276
- if PYDANTIC_V2:
277
- model_config = {"extra": "allow"}
276
+ if PYDANTIC_V2: # type: ignore [misc]
277
+ __pydantic_config__ = {"extra": "allow"}
278
278
 
279
279
  else:
280
280
 
fastapi/openapi/utils.py CHANGED
@@ -118,7 +118,9 @@ def get_openapi_operation_parameters(
118
118
  }
119
119
  if field_info.description:
120
120
  parameter["description"] = field_info.description
121
- if field_info.example != Undefined:
121
+ if field_info.openapi_examples:
122
+ parameter["examples"] = jsonable_encoder(field_info.openapi_examples)
123
+ elif field_info.example != Undefined:
122
124
  parameter["example"] = jsonable_encoder(field_info.example)
123
125
  if field_info.deprecated:
124
126
  parameter["deprecated"] = field_info.deprecated
@@ -153,7 +155,11 @@ def get_openapi_operation_request_body(
153
155
  if required:
154
156
  request_body_oai["required"] = required
155
157
  request_media_content: Dict[str, Any] = {"schema": body_schema}
156
- if field_info.example != Undefined:
158
+ if field_info.openapi_examples:
159
+ request_media_content["examples"] = jsonable_encoder(
160
+ field_info.openapi_examples
161
+ )
162
+ elif field_info.example != Undefined:
157
163
  request_media_content["example"] = jsonable_encoder(field_info.example)
158
164
  request_body_oai["content"] = {request_media_type: request_media_content}
159
165
  return request_body_oai
@@ -2,6 +2,7 @@ from typing import Any, Callable, Dict, List, Optional, Sequence, Union
2
2
 
3
3
  from fastapi import params
4
4
  from fastapi._compat import Undefined
5
+ from fastapi.openapi.models import Example
5
6
  from typing_extensions import Annotated, deprecated
6
7
 
7
8
  _Unset: Any = Undefined
@@ -46,6 +47,7 @@ def Path( # noqa: N802
46
47
  "although still supported. Use examples instead."
47
48
  ),
48
49
  ] = _Unset,
50
+ openapi_examples: Optional[Dict[str, Example]] = None,
49
51
  deprecated: Optional[bool] = None,
50
52
  include_in_schema: bool = True,
51
53
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -76,6 +78,7 @@ def Path( # noqa: N802
76
78
  decimal_places=decimal_places,
77
79
  example=example,
78
80
  examples=examples,
81
+ openapi_examples=openapi_examples,
79
82
  deprecated=deprecated,
80
83
  include_in_schema=include_in_schema,
81
84
  json_schema_extra=json_schema_extra,
@@ -122,6 +125,7 @@ def Query( # noqa: N802
122
125
  "although still supported. Use examples instead."
123
126
  ),
124
127
  ] = _Unset,
128
+ openapi_examples: Optional[Dict[str, Example]] = None,
125
129
  deprecated: Optional[bool] = None,
126
130
  include_in_schema: bool = True,
127
131
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -152,6 +156,7 @@ def Query( # noqa: N802
152
156
  decimal_places=decimal_places,
153
157
  example=example,
154
158
  examples=examples,
159
+ openapi_examples=openapi_examples,
155
160
  deprecated=deprecated,
156
161
  include_in_schema=include_in_schema,
157
162
  json_schema_extra=json_schema_extra,
@@ -199,6 +204,7 @@ def Header( # noqa: N802
199
204
  "although still supported. Use examples instead."
200
205
  ),
201
206
  ] = _Unset,
207
+ openapi_examples: Optional[Dict[str, Example]] = None,
202
208
  deprecated: Optional[bool] = None,
203
209
  include_in_schema: bool = True,
204
210
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -230,6 +236,7 @@ def Header( # noqa: N802
230
236
  decimal_places=decimal_places,
231
237
  example=example,
232
238
  examples=examples,
239
+ openapi_examples=openapi_examples,
233
240
  deprecated=deprecated,
234
241
  include_in_schema=include_in_schema,
235
242
  json_schema_extra=json_schema_extra,
@@ -276,6 +283,7 @@ def Cookie( # noqa: N802
276
283
  "although still supported. Use examples instead."
277
284
  ),
278
285
  ] = _Unset,
286
+ openapi_examples: Optional[Dict[str, Example]] = None,
279
287
  deprecated: Optional[bool] = None,
280
288
  include_in_schema: bool = True,
281
289
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -306,6 +314,7 @@ def Cookie( # noqa: N802
306
314
  decimal_places=decimal_places,
307
315
  example=example,
308
316
  examples=examples,
317
+ openapi_examples=openapi_examples,
309
318
  deprecated=deprecated,
310
319
  include_in_schema=include_in_schema,
311
320
  json_schema_extra=json_schema_extra,
@@ -354,6 +363,7 @@ def Body( # noqa: N802
354
363
  "although still supported. Use examples instead."
355
364
  ),
356
365
  ] = _Unset,
366
+ openapi_examples: Optional[Dict[str, Example]] = None,
357
367
  deprecated: Optional[bool] = None,
358
368
  include_in_schema: bool = True,
359
369
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -386,6 +396,7 @@ def Body( # noqa: N802
386
396
  decimal_places=decimal_places,
387
397
  example=example,
388
398
  examples=examples,
399
+ openapi_examples=openapi_examples,
389
400
  deprecated=deprecated,
390
401
  include_in_schema=include_in_schema,
391
402
  json_schema_extra=json_schema_extra,
@@ -433,6 +444,7 @@ def Form( # noqa: N802
433
444
  "although still supported. Use examples instead."
434
445
  ),
435
446
  ] = _Unset,
447
+ openapi_examples: Optional[Dict[str, Example]] = None,
436
448
  deprecated: Optional[bool] = None,
437
449
  include_in_schema: bool = True,
438
450
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -464,6 +476,7 @@ def Form( # noqa: N802
464
476
  decimal_places=decimal_places,
465
477
  example=example,
466
478
  examples=examples,
479
+ openapi_examples=openapi_examples,
467
480
  deprecated=deprecated,
468
481
  include_in_schema=include_in_schema,
469
482
  json_schema_extra=json_schema_extra,
@@ -511,6 +524,7 @@ def File( # noqa: N802
511
524
  "although still supported. Use examples instead."
512
525
  ),
513
526
  ] = _Unset,
527
+ openapi_examples: Optional[Dict[str, Example]] = None,
514
528
  deprecated: Optional[bool] = None,
515
529
  include_in_schema: bool = True,
516
530
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -542,6 +556,7 @@ def File( # noqa: N802
542
556
  decimal_places=decimal_places,
543
557
  example=example,
544
558
  examples=examples,
559
+ openapi_examples=openapi_examples,
545
560
  deprecated=deprecated,
546
561
  include_in_schema=include_in_schema,
547
562
  json_schema_extra=json_schema_extra,
fastapi/params.py CHANGED
@@ -2,6 +2,7 @@ import warnings
2
2
  from enum import Enum
3
3
  from typing import Any, Callable, Dict, List, Optional, Sequence, Union
4
4
 
5
+ from fastapi.openapi.models import Example
5
6
  from pydantic.fields import FieldInfo
6
7
  from typing_extensions import Annotated, deprecated
7
8
 
@@ -61,6 +62,7 @@ class Param(FieldInfo):
61
62
  "although still supported. Use examples instead."
62
63
  ),
63
64
  ] = _Unset,
65
+ openapi_examples: Optional[Dict[str, Example]] = None,
64
66
  deprecated: Optional[bool] = None,
65
67
  include_in_schema: bool = True,
66
68
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -75,6 +77,7 @@ class Param(FieldInfo):
75
77
  )
76
78
  self.example = example
77
79
  self.include_in_schema = include_in_schema
80
+ self.openapi_examples = openapi_examples
78
81
  kwargs = dict(
79
82
  default=default,
80
83
  default_factory=default_factory,
@@ -170,6 +173,7 @@ class Path(Param):
170
173
  "although still supported. Use examples instead."
171
174
  ),
172
175
  ] = _Unset,
176
+ openapi_examples: Optional[Dict[str, Example]] = None,
173
177
  deprecated: Optional[bool] = None,
174
178
  include_in_schema: bool = True,
175
179
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -204,6 +208,7 @@ class Path(Param):
204
208
  deprecated=deprecated,
205
209
  example=example,
206
210
  examples=examples,
211
+ openapi_examples=openapi_examples,
207
212
  include_in_schema=include_in_schema,
208
213
  json_schema_extra=json_schema_extra,
209
214
  **extra,
@@ -254,6 +259,7 @@ class Query(Param):
254
259
  "although still supported. Use examples instead."
255
260
  ),
256
261
  ] = _Unset,
262
+ openapi_examples: Optional[Dict[str, Example]] = None,
257
263
  deprecated: Optional[bool] = None,
258
264
  include_in_schema: bool = True,
259
265
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -286,6 +292,7 @@ class Query(Param):
286
292
  deprecated=deprecated,
287
293
  example=example,
288
294
  examples=examples,
295
+ openapi_examples=openapi_examples,
289
296
  include_in_schema=include_in_schema,
290
297
  json_schema_extra=json_schema_extra,
291
298
  **extra,
@@ -337,6 +344,7 @@ class Header(Param):
337
344
  "although still supported. Use examples instead."
338
345
  ),
339
346
  ] = _Unset,
347
+ openapi_examples: Optional[Dict[str, Example]] = None,
340
348
  deprecated: Optional[bool] = None,
341
349
  include_in_schema: bool = True,
342
350
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -370,6 +378,7 @@ class Header(Param):
370
378
  deprecated=deprecated,
371
379
  example=example,
372
380
  examples=examples,
381
+ openapi_examples=openapi_examples,
373
382
  include_in_schema=include_in_schema,
374
383
  json_schema_extra=json_schema_extra,
375
384
  **extra,
@@ -420,6 +429,7 @@ class Cookie(Param):
420
429
  "although still supported. Use examples instead."
421
430
  ),
422
431
  ] = _Unset,
432
+ openapi_examples: Optional[Dict[str, Example]] = None,
423
433
  deprecated: Optional[bool] = None,
424
434
  include_in_schema: bool = True,
425
435
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -452,6 +462,7 @@ class Cookie(Param):
452
462
  deprecated=deprecated,
453
463
  example=example,
454
464
  examples=examples,
465
+ openapi_examples=openapi_examples,
455
466
  include_in_schema=include_in_schema,
456
467
  json_schema_extra=json_schema_extra,
457
468
  **extra,
@@ -502,6 +513,7 @@ class Body(FieldInfo):
502
513
  "although still supported. Use examples instead."
503
514
  ),
504
515
  ] = _Unset,
516
+ openapi_examples: Optional[Dict[str, Example]] = None,
505
517
  deprecated: Optional[bool] = None,
506
518
  include_in_schema: bool = True,
507
519
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -518,6 +530,7 @@ class Body(FieldInfo):
518
530
  )
519
531
  self.example = example
520
532
  self.include_in_schema = include_in_schema
533
+ self.openapi_examples = openapi_examples
521
534
  kwargs = dict(
522
535
  default=default,
523
536
  default_factory=default_factory,
@@ -613,6 +626,7 @@ class Form(Body):
613
626
  "although still supported. Use examples instead."
614
627
  ),
615
628
  ] = _Unset,
629
+ openapi_examples: Optional[Dict[str, Example]] = None,
616
630
  deprecated: Optional[bool] = None,
617
631
  include_in_schema: bool = True,
618
632
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -647,6 +661,7 @@ class Form(Body):
647
661
  deprecated=deprecated,
648
662
  example=example,
649
663
  examples=examples,
664
+ openapi_examples=openapi_examples,
650
665
  include_in_schema=include_in_schema,
651
666
  json_schema_extra=json_schema_extra,
652
667
  **extra,
@@ -696,6 +711,7 @@ class File(Form):
696
711
  "although still supported. Use examples instead."
697
712
  ),
698
713
  ] = _Unset,
714
+ openapi_examples: Optional[Dict[str, Example]] = None,
699
715
  deprecated: Optional[bool] = None,
700
716
  include_in_schema: bool = True,
701
717
  json_schema_extra: Union[Dict[str, Any], None] = None,
@@ -729,6 +745,7 @@ class File(Form):
729
745
  deprecated=deprecated,
730
746
  example=example,
731
747
  examples=examples,
748
+ openapi_examples=openapi_examples,
732
749
  include_in_schema=include_in_schema,
733
750
  json_schema_extra=json_schema_extra,
734
751
  **extra,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastapi
3
- Version: 0.102.0
3
+ Version: 0.103.0
4
4
  Summary: FastAPI framework, high performance, easy to learn, fast to code, ready for production
5
5
  Project-URL: Homepage, https://github.com/tiangolo/fastapi
6
6
  Project-URL: Documentation, https://fastapi.tiangolo.com/
@@ -1,4 +1,4 @@
1
- fastapi/__init__.py,sha256=9rDgMb5-jWs7d6iWSLEk71ixy123N0THKS_H8CxiIdk,1081
1
+ fastapi/__init__.py,sha256=h0fWTZ2oDwWSIdR2lMOSBUBP2yKgc0EastyxddBu5Aw,1081
2
2
  fastapi/_compat.py,sha256=rIhdPUb9XYHxkeCJH1EdVDB3d93Ne2cGhlHb65p9edY,22568
3
3
  fastapi/applications.py,sha256=hCZttoVGHOZ2jRMwJ_ntXFzjuAXVreFGv5mPhy6MFaA,40230
4
4
  fastapi/background.py,sha256=HtN5_pJJrOdalSbuGSMKJAPNWUU5h7rY_BXXubu7-IQ,76
@@ -8,8 +8,8 @@ fastapi/encoders.py,sha256=4EZEx0D8NjMLr793L9gBSc867V_WwsA22LWxroPy13Y,8044
8
8
  fastapi/exception_handlers.py,sha256=MBrIOA-ugjJDivIi4rSsUJBdTsjuzN76q4yh0q1COKw,1332
9
9
  fastapi/exceptions.py,sha256=svNjh4_VJogfG3dzsn21TtwOxy6l-bXIoYxoUjAxteI,1585
10
10
  fastapi/logger.py,sha256=I9NNi3ov8AcqbsbC9wl1X-hdItKgYt2XTrx1f99Zpl4,54
11
- fastapi/param_functions.py,sha256=ycrVFfSANRCgaAaRT7pC9_5okx_e4D0L8NUz6wTUKAw,18411
12
- fastapi/params.py,sha256=3WiA6CdfbtvVM6-TYdsFfIICNZx64ZeuQ77_R5LiVq4,26880
11
+ fastapi/param_functions.py,sha256=_bqVX6LLUFjFOuua7UBIP3dXRpcdyrsnFEwPqBokwV8,19168
12
+ fastapi/params.py,sha256=LzjihAvODd3w7-GddraUyVtH1xfwR9smIoQn-Z_g4mg,27807
13
13
  fastapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  fastapi/requests.py,sha256=zayepKFcienBllv3snmWI20Gk0oHNVLU4DDhqXBb4LU,142
15
15
  fastapi/responses.py,sha256=on95e4CfSRyNz7MEjqFuzsP-eW8kHWTxEl_Z-Vzb7lA,1242
@@ -33,8 +33,8 @@ fastapi/middleware/wsgi.py,sha256=Z3Ue-7wni4lUZMvH3G9ek__acgYdJstbnpZX_HQAboY,79
33
33
  fastapi/openapi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  fastapi/openapi/constants.py,sha256=adGzmis1L1HJRTE3kJ5fmHS_Noq6tIY6pWv_SFzoFDU,153
35
35
  fastapi/openapi/docs.py,sha256=HbP76-u4A45BrL4WjLMhA3MBVI9xMx7XiMyDRS_ZO0E,6532
36
- fastapi/openapi/models.py,sha256=G_yoz3jFjCDZVE5xW0vcQPXRljtqhnbGR8oogEnr-Hc,17733
37
- fastapi/openapi/utils.py,sha256=wPRHgz5ZIAZOzx2hU6NA7C9lh919NYZL04gE2CVpTNM,22029
36
+ fastapi/openapi/models.py,sha256=alc7SWZeDXSWWC-HMdsVGy53BuS2RBbGpK_IiSgaREA,17759
37
+ fastapi/openapi/utils.py,sha256=PUuz_ISarHVPBRyIgfyHz8uwH0eEsDY3rJUfW__I9GI,22303
38
38
  fastapi/security/__init__.py,sha256=bO8pNmxqVRXUjfl2mOKiVZLn0FpBQ61VUYVjmppnbJw,881
39
39
  fastapi/security/api_key.py,sha256=92kxZjj9OuIvQCUpLszP9qlILRgx6hCh1x-bZdhmQDU,2939
40
40
  fastapi/security/base.py,sha256=dl4pvbC-RxjfbWgPtCWd8MVU-7CB2SZ22rJDXVCXO6c,141
@@ -42,7 +42,7 @@ fastapi/security/http.py,sha256=VbTm1k6t6EjJAnCnYVquSOmSK7fATdKRgq0-TgC7FnQ,5964
42
42
  fastapi/security/oauth2.py,sha256=fXQdWuTtUKSZ9Lyrj9fDuQoXAmXTd9AVFDrrwStJKX0,8579
43
43
  fastapi/security/open_id_connect_url.py,sha256=GKK84g6OZbOFCEZJyd27pGjpaClGxeZrYOemUzyhfbU,1141
44
44
  fastapi/security/utils.py,sha256=bd8T0YM7UQD5ATKucr1bNtAvz_Y3__dVNAv5UebiPvc,293
45
- fastapi-0.102.0.dist-info/METADATA,sha256=zOGiKhJjW5Q2oJHn9z_t4I3xMbf34hqbyjVTXraUPbo,24070
46
- fastapi-0.102.0.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
47
- fastapi-0.102.0.dist-info/licenses/LICENSE,sha256=Tsif_IFIW5f-xYSy1KlhAy7v_oNEU4lP2cEnSQbMdE4,1086
48
- fastapi-0.102.0.dist-info/RECORD,,
45
+ fastapi-0.103.0.dist-info/METADATA,sha256=5IzAieglNHsMCxopNzH1c8vkT2v_UnRyLDJ2zYu9ZLg,24070
46
+ fastapi-0.103.0.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
47
+ fastapi-0.103.0.dist-info/licenses/LICENSE,sha256=Tsif_IFIW5f-xYSy1KlhAy7v_oNEU4lP2cEnSQbMdE4,1086
48
+ fastapi-0.103.0.dist-info/RECORD,,