Initial Implementation of Default

This commit is contained in:
2025-04-09 23:47:40 -03:00
parent 903c6ea08b
commit a571e28015
2 changed files with 23 additions and 1 deletions

View File

@@ -179,3 +179,25 @@ class TestSchemaConverter(TestCase):
self.assertEqual(obj.address.street, "123 Main St")
self.assertEqual(obj.address.city, "Springfield")
def test_default(self):
schema = {
"title": "Person",
"description": "A person",
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {
"type": "integer",
"default": 30,
},
},
"required": ["name"],
}
model = SchemaConverter.build(schema)
obj = model(name="John")
self.assertEqual(obj.name, "John")
self.assertEqual(obj.age, 30)