diff --git a/docs/source/usage.object.rst b/docs/source/usage.object.rst new file mode 100644 index 0000000..709d0b9 --- /dev/null +++ b/docs/source/usage.object.rst @@ -0,0 +1,46 @@ +Object Type +================= + + +The Bool type has no specific properties, it has only the generic properties: + +- default: Default value for the string. +- description: Description of the string field. + + +Examples +----------------- + + +.. code-block:: python + + from jambo import SchemaConverter + + schema = { + "title": "Person", + "type": "object", + "properties": { + "address": { + "type": "object", + "properties": { + "street": {"type": "string"}, + "city": {"type": "string"}, + }, + "default": { + "street": "Unknown Street", + "city": "Unknown City", + }, + }, + }, + "description": "A person object containing a address.", + "required": ["address"], + } + + + Person = SchemaConverter.build(schema) + + obj = Person.model_validate({ "address": {"street": "123 Main St", "city": "Springfield"} }) + print(obj) # Output: Person(address=Address(street='123 Main St', city='Springfield')) + + obj_default = Person() # Uses default values + print(obj_default) # Output: Person(address=Address(street='Unknown Street', city='Unknown City')) diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 92ce265..b3ba7b9 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -40,4 +40,5 @@ For more complex schemas and types see our documentation on usage.string usage.numeric usage.bool - usage.array \ No newline at end of file + usage.array + usage.object \ No newline at end of file