|
|
|
@ -4,6 +4,7 @@ from dataclasses import dataclass |
|
|
|
from enum import Enum |
|
|
|
from typing import Annotated, Any, Callable, Optional, Union |
|
|
|
|
|
|
|
from fastapi.exceptions import FastAPIDeprecationWarning |
|
|
|
from fastapi.openapi.models import Example |
|
|
|
from pydantic.fields import FieldInfo |
|
|
|
from typing_extensions import Literal, deprecated |
|
|
|
@ -75,7 +76,7 @@ class Param(FieldInfo): # type: ignore[misc] |
|
|
|
if example is not _Unset: |
|
|
|
warnings.warn( |
|
|
|
"`example` has been deprecated, please use `examples` instead", |
|
|
|
category=DeprecationWarning, |
|
|
|
category=FastAPIDeprecationWarning, |
|
|
|
stacklevel=4, |
|
|
|
) |
|
|
|
self.example = example |
|
|
|
@ -105,7 +106,7 @@ class Param(FieldInfo): # type: ignore[misc] |
|
|
|
if regex is not None: |
|
|
|
warnings.warn( |
|
|
|
"`regex` has been deprecated, please use `pattern` instead", |
|
|
|
category=DeprecationWarning, |
|
|
|
category=FastAPIDeprecationWarning, |
|
|
|
stacklevel=4, |
|
|
|
) |
|
|
|
current_json_schema_extra = json_schema_extra or extra |
|
|
|
@ -530,7 +531,7 @@ class Body(FieldInfo): # type: ignore[misc] |
|
|
|
if example is not _Unset: |
|
|
|
warnings.warn( |
|
|
|
"`example` has been deprecated, please use `examples` instead", |
|
|
|
category=DeprecationWarning, |
|
|
|
category=FastAPIDeprecationWarning, |
|
|
|
stacklevel=4, |
|
|
|
) |
|
|
|
self.example = example |
|
|
|
@ -560,7 +561,7 @@ class Body(FieldInfo): # type: ignore[misc] |
|
|
|
if regex is not None: |
|
|
|
warnings.warn( |
|
|
|
"`regex` has been deprecated, please use `pattern` instead", |
|
|
|
category=DeprecationWarning, |
|
|
|
category=FastAPIDeprecationWarning, |
|
|
|
stacklevel=4, |
|
|
|
) |
|
|
|
current_json_schema_extra = json_schema_extra or extra |
|
|
|
|