feat: Add examples #54

Merged
JCHacking merged 14 commits from examples into main 2025-11-23 23:10:27 +00:00
2 changed files with 22 additions and 0 deletions
Showing only changes of commit c7e366cf08 - Show all commits

View File

@@ -310,3 +310,14 @@ class TestStringTypeParser(TestCase):
timedelta(seconds=0.5),
],
)
def test_string_parser_with_invalid_example_value(self):
with self.assertRaises(InvalidSchemaException):
StringTypeParser().from_properties(
"placeholder",
{
"type": "string",
"format": "email",
"examples": ["invalid-email"],
},
)

View File

@@ -20,3 +20,14 @@ class TestGenericTypeParser(TestCase):
def test_get_impl_invalid_type(self):
with self.assertRaises(InvalidSchemaException):
GenericTypeParser._get_impl({"type": "invalid_type"})
def test_invalid_examples_not_list(self):
parser = StringTypeParser()
properties = {
"type": "integer",
"examples": "this should be a list",
}
with self.assertRaises(InvalidSchemaException):
parser.from_properties("placeholder", properties)