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
3 changes: 2 additions & 1 deletion openapi_core/unmarshalling/schemas/unmarshallers.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def items_unmarshaller(self):

def __call__(self, value=NoValue):
value = super(ArrayUnmarshaller, self).__call__(value)

if value is None and self.schema.nullable:
return None
return list(map(self.items_unmarshaller, value))


Expand Down
21 changes: 21 additions & 0 deletions tests/unit/unmarshalling/test_unmarshal.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,27 @@ def test_array_valid(self, unmarshaller_factory):

assert result == value

def test_array_null(self, unmarshaller_factory):
schema = Schema(
'array',
items=Schema('integer'),
)
value = None

with pytest.raises(TypeError):
unmarshaller_factory(schema)(value)

def test_array_nullable(self, unmarshaller_factory):
schema = Schema(
'array',
items=Schema('integer'),
nullable=True,
)
value = None
result = unmarshaller_factory(schema)(value)

assert result is None

def test_array_of_string_string_invalid(self, unmarshaller_factory):
schema = Schema('array', items=Schema('string'))
value = '123'
Expand Down