diff --git a/openapi_core/unmarshalling/schemas/unmarshallers.py b/openapi_core/unmarshalling/schemas/unmarshallers.py index ef0fdb7..83a47dc 100644 --- a/openapi_core/unmarshalling/schemas/unmarshallers.py +++ b/openapi_core/unmarshalling/schemas/unmarshallers.py @@ -248,7 +248,7 @@ class AnyUnmarshaller(ComplexUnmarshaller): SchemaType.INTEGER, SchemaType.NUMBER, SchemaType.STRING, ] - def __call__(self, value=NoValue): + def unmarshal(self, value=NoValue): one_of_schema = self._get_one_of_schema(value) if one_of_schema: return self.unmarshallers_factory.create(one_of_schema)(value) diff --git a/tests/unit/unmarshalling/test_unmarshal.py b/tests/unit/unmarshalling/test_unmarshal.py index 1c7e145..906689e 100644 --- a/tests/unit/unmarshalling/test_unmarshal.py +++ b/tests/unit/unmarshalling/test_unmarshal.py @@ -476,6 +476,52 @@ class TestSchemaUnmarshallerCall(object): ]) assert unmarshaller_factory(schema)(['hello']) == ['hello'] + @pytest.mark.parametrize('value', [ + { + 'somestr': {}, + 'someint': 123, + }, + { + 'somestr': [ + 'content1', 'content2' + ], + 'someint': 123, + }, + { + 'somestr': 123, + 'someint': 123, + }, + { + 'somestr': 'content', + 'someint': 123, + 'not_in_scheme_prop': 123, + }, + ]) + def test_schema_any_all_of_invalid_properties( + self, value, unmarshaller_factory): + schema = Schema( + all_of=[ + Schema( + 'object', + required=['somestr'], + properties={ + 'somestr': Schema('string'), + }, + ), + Schema( + 'object', + required=['someint'], + properties={ + 'someint': Schema('integer'), + }, + ), + ], + additional_properties=False, + ) + + with pytest.raises(InvalidSchemaValue): + unmarshaller_factory(schema)(value) + def test_schema_any_all_of_any(self, unmarshaller_factory): schema = Schema(all_of=[ Schema(),