mirror of https://github.com/tiangolo/fastapi.git
Attempt to use pydantic_extra_types and allow the deprecated v1 Color
This commit is contained in:
parent
4b23d86921
commit
d23967f756
|
|
@ -28,7 +28,10 @@ from annotated_doc import Doc
|
|||
from fastapi.exceptions import PydanticV1NotSupportedError
|
||||
from fastapi.types import IncEx
|
||||
from pydantic import BaseModel
|
||||
from pydantic.color import Color
|
||||
try:
|
||||
from pydantic_extra_types.color import Color
|
||||
except ImportError:
|
||||
from pydantic.color import Color
|
||||
from pydantic.networks import AnyUrl, NameEmail
|
||||
from pydantic.types import SecretBytes, SecretStr
|
||||
from pydantic_core import PydanticUndefinedType
|
||||
|
|
@ -76,7 +79,6 @@ ENCODERS_BY_TYPE: dict[type[Any], Callable[[Any], Any]] = {
|
|||
bytes: lambda o: o.decode(),
|
||||
Color: str,
|
||||
Coordinate: str,
|
||||
may_v1.Color: str,
|
||||
datetime.date: isoformat,
|
||||
datetime.datetime: isoformat,
|
||||
datetime.time: isoformat,
|
||||
|
|
|
|||
Loading…
Reference in New Issue