Skip to content

Commit 26c4a99

Browse files
committed
deepObject - v1 compat glue
1 parent fbbb8ec commit 26c4a99

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

fastapi/dependencies/utils.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import dataclasses
21
import collections
2+
import dataclasses
33
import inspect
44
import re
5-
import sys
65
from contextlib import AsyncExitStack, contextmanager
76
from copy import copy, deepcopy
87
from dataclasses import dataclass
@@ -23,7 +22,7 @@
2322
)
2423

2524
import anyio
26-
from fastapi import params
25+
from fastapi import params, temp_pydantic_v1_params
2726
from fastapi._compat import (
2827
PYDANTIC_V2,
2928
ModelField,
@@ -81,8 +80,6 @@
8180
from starlette.websockets import WebSocket
8281
from typing_extensions import Annotated, Literal, get_args, get_origin
8382

84-
from .. import temp_pydantic_v1_params
85-
8683
multipart_not_installed_error = (
8784
'Form data requires "python-multipart" to be installed. \n'
8885
'You can install "python-multipart" with: \n\n'
@@ -754,20 +751,24 @@ def _default() -> Dict[str, Any]:
754751

755752
@staticmethod
756753
def decode(
757-
field_info: params.Param,
754+
field_info: Union[params.Param, temp_pydantic_v1_params.Param],
758755
received_params: Union[Mapping[str, Any], QueryParams, Headers],
759756
field: ModelField,
760757
) -> Dict[str, Any]:
761758
fn: Callable[
762-
[params.Param, Union[Mapping[str, Any], QueryParams, Headers], ModelField],
759+
[
760+
Union[params.Param, temp_pydantic_v1_params.Param],
761+
Union[Mapping[str, Any], QueryParams, Headers],
762+
ModelField,
763+
],
763764
Dict[str, Any],
764765
]
765766
fn = getattr(ParameterCodec, f"decode_{field_info.style}")
766767
return fn(field_info, received_params, field)
767768

768769
@staticmethod
769770
def decode_deepObject(
770-
field_info: params.Param,
771+
field_info: Union[params.Param, temp_pydantic_v1_params.Param],
771772
received_params: Union[Mapping[str, Any], QueryParams, Headers],
772773
field: ModelField,
773774
) -> Dict[str, Any]:

fastapi/temp_pydantic_v1_params.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def __init__(
5959
deprecated: Union[deprecated, str, bool, None] = None,
6060
include_in_schema: bool = True,
6161
json_schema_extra: Union[Dict[str, Any], None] = None,
62+
style: str = _Unset,
63+
explode: bool = _Unset,
6264
**extra: Any,
6365
):
6466
if example is not _Unset:
@@ -107,6 +109,8 @@ def __init__(
107109
use_kwargs = {k: v for k, v in kwargs.items() if v is not _Unset}
108110

109111
super().__init__(**use_kwargs)
112+
self.style = style
113+
self.explode = explode
110114

111115
def __repr__(self) -> str:
112116
return f"{self.__class__.__name__}({self.default})"

0 commit comments

Comments
 (0)