feat: adds support for list of types

This commit is contained in:
2025-11-26 10:42:15 -03:00
parent 79e65b994e
commit d418ad96ad
4 changed files with 91 additions and 4 deletions

View File

@@ -998,3 +998,52 @@ class TestSchemaConverter(TestCase):
cached_address_model = self.converter.get_cached_ref("address")
self.assertIsNotNone(cached_address_model)
def test_parse_list_type_multiple_values(self):
schema = {
"title": "TestListType",
"type": "object",
"properties": {
"values": {
"type": ["string", "number"]
}
},
}
Model = self.converter.build_with_cache(schema)
obj1 = Model(values="a string")
self.assertEqual(obj1.values, "a string")
obj2 = Model(values=42)
self.assertEqual(obj2.values, 42)
def test_parse_list_type_one_value(self):
schema = {
"title": "TestListType",
"type": "object",
"properties": {
"values": {
"type": ["string"]
}
},
}
Model = self.converter.build_with_cache(schema)
obj1 = Model(values="a string")
self.assertEqual(obj1.values, "a string")
def test_parse_list_type_empty(self):
schema = {
"title": "TestListType",
"type": "object",
"properties": {
"values": {
"type": []
}
},
}
with self.assertRaises(InvalidSchemaException):
self.converter.build_with_cache(schema)