feat: validates that top level type cannot be list
This commit is contained in:
@@ -138,9 +138,8 @@ class SchemaConverter:
|
|||||||
|
|
||||||
type_value = schema.get("type")
|
type_value = schema.get("type")
|
||||||
if isinstance(type_value, list):
|
if isinstance(type_value, list):
|
||||||
raise InternalAssertionException(
|
raise InvalidSchemaException(
|
||||||
"SchemaConverter._get_schema_type: 'type' field should not be a list here."
|
"Invalid schema: 'type' cannot be a list at the top level", invalid_field=str(schema)
|
||||||
" This should have been normalized earlier."
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return type_value
|
return type_value
|
||||||
|
|||||||
@@ -1047,3 +1047,12 @@ class TestSchemaConverter(TestCase):
|
|||||||
|
|
||||||
with self.assertRaises(InvalidSchemaException):
|
with self.assertRaises(InvalidSchemaException):
|
||||||
self.converter.build_with_cache(schema)
|
self.converter.build_with_cache(schema)
|
||||||
|
|
||||||
|
def test_parse_list_type_root_level_throws(self):
|
||||||
|
schema = {
|
||||||
|
"title": "TestListType",
|
||||||
|
"type": ["string", "number"]
|
||||||
|
}
|
||||||
|
|
||||||
|
with self.assertRaises(InvalidSchemaException):
|
||||||
|
self.converter.build_with_cache(schema)
|
||||||
Reference in New Issue
Block a user