Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions openapi_core/unmarshalling/schemas/unmarshallers.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,16 @@ class ObjectUnmarshaller(ComplexUnmarshaller):
def model_factory(self):
return ModelFactory()

def __call__(self, value=NoValue):
value = super(ObjectUnmarshaller, self).__call__(value)
def unmarshal(self, value):
try:
value = self.formatter.unmarshal(value)
except ValueError as exc:
raise InvalidSchemaFormatValue(
value, self.schema.format, exc)
else:
return self._unmarshal_object(value)

def _unmarshal_object(self, value=NoValue):
if self.schema.one_of:
properties = None
for one_of_schema in self.schema.one_of:
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/unmarshalling/test_unmarshal.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,18 @@ def test_number_format_double(self, unmarshaller_factory):

assert result == 1.2

def test_object_nullable(self, unmarshaller_factory):
schema = Schema(
'object',
properties={
'foo': Schema('object', nullable=True),
},
)
value = {'foo': None}
result = unmarshaller_factory(schema)(value)

assert result == {'foo': None}

def test_schema_any_one_of(self, unmarshaller_factory):
schema = Schema(one_of=[
Schema('string'),
Expand Down