feat: fixes and validates that objects have parsed examples
This commit is contained in:
@@ -21,13 +21,18 @@ class ObjectTypeParser(GenericTypeParser):
|
||||
properties.get("required", []),
|
||||
**kwargs,
|
||||
)
|
||||
type_properties = {}
|
||||
type_properties = self.mappings_properties_builder(properties, **kwargs)
|
||||
|
||||
if "default" in properties:
|
||||
if (default_value := type_properties.get("default")) is not None:
|
||||
type_properties["default_factory"] = lambda: type_parsing.model_validate(
|
||||
properties["default"]
|
||||
default_value
|
||||
)
|
||||
|
||||
if (example_values := type_properties.get("examples")) is not None:
|
||||
type_properties["examples"] = [
|
||||
type_parsing.model_validate(example) for example in example_values
|
||||
]
|
||||
|
||||
return type_parsing, type_properties
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user