diff --git a/flattentool/schema.py b/flattentool/schema.py index 81ecfa68..97e7c83e 100644 --- a/flattentool/schema.py +++ b/flattentool/schema.py @@ -147,7 +147,11 @@ def parse_schema_dict(self, parent_path, schema_dict, parent_id_fields=None, tit elif 'array' in property_type_set: flattened_key = parent_path.replace('/0/', '/')+property_name self.flattened[flattened_key] = "array" - type_set = get_property_type_set(property_schema_dict['items']) + if isinstance(property_schema_dict['items'], list): + # If we have a list under items, just use the first one + type_set = get_property_type_set(property_schema_dict['items'][0]) + else: + type_set = get_property_type_set(property_schema_dict['items']) if 'string' in type_set or not type_set: self.flattened[flattened_key] = "string_array" yield property_name, title diff --git a/flattentool/tests/test_schema_parser.py b/flattentool/tests/test_schema_parser.py index da72707b..3abce057 100644 --- a/flattentool/tests/test_schema_parser.py +++ b/flattentool/tests/test_schema_parser.py @@ -282,6 +282,33 @@ def test_simple_array(type_): assert set(parser.main_sheet) == set(['Atest']) +@pytest.mark.parametrize('type_', ['string', 'number']) +def test_double_array(type_): + """ + Make sure we handle an array under items, used for e.g. co-ordinates. + + """ + parser = SchemaParser( + root_schema_dict={ + 'properties': { + 'Atest': { + 'type': 'array', + 'items': [ + { + 'type': type_ + }, + { + 'type': type_ + } + ] + } + } + } + ) + parser.parse() + assert set(parser.main_sheet) == set(['Atest']) + + @pytest.mark.parametrize('type_', ['string', 'number']) def test_nested_simple_array(type_): parser = SchemaParser(