Merge pull request #32 from fredsonnenwald/add-null

Add null type parser
This commit was merged in pull request #32.
This commit is contained in:
2025-08-18 23:39:11 -03:00
committed by GitHub
4 changed files with 69 additions and 0 deletions

View File

@@ -700,3 +700,23 @@ class TestSchemaConverter(TestCase):
with self.assertRaises(ValueError):
Model(name="Canada")
def test_null_type_parser(self):
schema = {
"title": "Test",
"type": "object",
"properties": {
"a_thing": {"type": "null"},
},
}
Model = SchemaConverter.build(schema)
obj = Model()
self.assertIsNone(obj.a_thing)
obj = Model(a_thing=None)
self.assertIsNone(obj.a_thing)
with self.assertRaises(ValueError):
Model(a_thing="not none")