Skip to content

Commit 706ea03

Browse files
committed
any unmarshaller types fix
1 parent 0ff6315 commit 706ea03

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

Diff for: openapi_core/unmarshalling/schemas/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636

3737
oas30_unmarshallers_dict = OrderedDict(
3838
[
39-
("string", PrimitiveUnmarshaller),
39+
("object", ObjectUnmarshaller),
40+
("array", ArrayUnmarshaller),
41+
("boolean", PrimitiveUnmarshaller),
4042
("integer", PrimitiveUnmarshaller),
4143
("number", PrimitiveUnmarshaller),
42-
("boolean", PrimitiveUnmarshaller),
43-
("array", ArrayUnmarshaller),
44-
("object", ObjectUnmarshaller),
44+
("string", PrimitiveUnmarshaller),
4545
]
4646
)
4747
oas31_unmarshallers_dict = oas30_unmarshallers_dict.copy()

Diff for: openapi_core/unmarshalling/schemas/unmarshallers.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,9 @@ def _get_best_unmarshaller(self, value: Any) -> "PrimitiveUnmarshaller":
167167

168168

169169
class AnyUnmarshaller(MultiTypeUnmarshaller):
170-
SCHEMA_TYPES_ORDER = [
171-
"object",
172-
"array",
173-
"boolean",
174-
"integer",
175-
"number",
176-
"string",
177-
]
178-
179170
@property
180171
def type(self) -> List[str]:
181-
return self.SCHEMA_TYPES_ORDER
172+
return self.schema_unmarshaller.types_unmarshaller.get_types()
182173

183174

184175
class TypesUnmarshaller:
@@ -195,6 +186,9 @@ def __init__(
195186
self.default = default
196187
self.multi = multi
197188

189+
def get_types(self) -> List[str]:
190+
return list(self.unmarshallers.keys())
191+
198192
def get_unmarshaller(
199193
self,
200194
schema_type: Optional[Union[Iterable[str], str]],

Diff for: tests/integration/unmarshalling/test_unmarshallers.py

+9
Original file line numberDiff line numberDiff line change
@@ -2059,3 +2059,12 @@ def test_nultiple_types_invalid(self, unmarshallers_factory, types, value):
20592059
unmarshaller.unmarshal(value)
20602060
assert len(exc_info.value.schema_errors) == 1
20612061
assert "is not of type" in exc_info.value.schema_errors[0].message
2062+
2063+
def test_any_null(self, unmarshallers_factory):
2064+
schema = {}
2065+
spec = Spec.from_dict(schema, validator=None)
2066+
unmarshaller = unmarshallers_factory.create(spec)
2067+
2068+
result = unmarshaller.unmarshal(None)
2069+
2070+
assert result is None

0 commit comments

Comments
 (0)