From 12471ac8046f4e1e832aa6c93bcfedb3915b8f59 Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Date: Fri, 20 Jun 2025 23:25:10 -0300 Subject: [PATCH] Adds Docs for Object --- docs/source/usage.object.rst | 46 ++++++++++++++++++++++++++++++++++++ docs/source/usage.rst | 3 ++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 docs/source/usage.object.rst 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