feat: fixes broken example property extraction in array type parser
This commit is contained in:
@@ -3,23 +3,14 @@ from jambo.parser._type_parser import GenericTypeParser
|
|||||||
from jambo.types.type_parser_options import TypeParserOptions
|
from jambo.types.type_parser_options import TypeParserOptions
|
||||||
|
|
||||||
from typing_extensions import (
|
from typing_extensions import (
|
||||||
Callable,
|
|
||||||
Generic,
|
|
||||||
Iterable,
|
Iterable,
|
||||||
Optional,
|
|
||||||
TypeVar,
|
|
||||||
Union,
|
|
||||||
Unpack,
|
Unpack,
|
||||||
)
|
)
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
|
||||||
V = TypeVar("V")
|
class ArrayTypeParser(GenericTypeParser):
|
||||||
T = TypeVar("T", bound=list)
|
|
||||||
|
|
||||||
|
|
||||||
class ArrayTypeParser(GenericTypeParser, Generic[T, V]):
|
|
||||||
mapped_type = list
|
mapped_type = list
|
||||||
|
|
||||||
json_schema_type = "type:array"
|
json_schema_type = "type:array"
|
||||||
@@ -57,18 +48,14 @@ class ArrayTypeParser(GenericTypeParser, Generic[T, V]):
|
|||||||
default_value, wrapper_type
|
default_value, wrapper_type
|
||||||
)
|
)
|
||||||
|
|
||||||
if (
|
if (example_values := mapped_properties.pop("examples", None)) is not None:
|
||||||
example_values := mapped_properties.pop("example_values", None)
|
|
||||||
) is not None:
|
|
||||||
mapped_properties["examples"] = [
|
mapped_properties["examples"] = [
|
||||||
wrapper_type(example) for example in example_values
|
wrapper_type(example) for example in example_values
|
||||||
]
|
]
|
||||||
|
|
||||||
return field_type, mapped_properties
|
return field_type, mapped_properties
|
||||||
|
|
||||||
def _build_default_factory(
|
def _build_default_factory(self, default_list, wrapper_type):
|
||||||
self, default_list: Optional[Iterable[V]], wrapper_type: type[V]
|
|
||||||
) -> Callable[[], Union[V, None]]:
|
|
||||||
if default_list is None:
|
if default_list is None:
|
||||||
return lambda: None
|
return lambda: None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user