Initial Implementation of $ref

This commit is contained in:
2025-06-12 01:54:52 -03:00
parent 129114a85f
commit 760f30d08f
4 changed files with 111 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
from jambo.parser import RefTypeParser
from unittest import TestCase
class TestRefTypeParser(TestCase):
def test_ref_type_parser_local_ref(self):
properties = {
"title": "person",
"$ref": "#/$defs/person",
"$defs": {
"person": {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
},
}
},
}
type_parsing, type_validator = RefTypeParser().from_properties(
properties=properties,
name="placeholder",
context=properties,
required=True,
)
self.assertIsInstance(type_parsing, type)
obj = type_parsing(name="John", age=30)
self.assertEqual(obj.name, "John")
self.assertEqual(obj.age, 30)