fix(jambo): Fix allOf, anyOf, null and array type parsing #33

Closed
thommann wants to merge 10 commits from main into main
2 changed files with 16 additions and 3 deletions
Showing only changes of commit 053279ba95 - Show all commits

View File

@@ -1,7 +1,7 @@
from jambo.parser._type_parser import GenericTypeParser
from jambo.types.type_parser_options import TypeParserOptions
from pydantic import EmailStr, HttpUrl, IPvAnyAddress
from pydantic import EmailStr, HttpUrl, IPvAnyAddress, FilePath
from typing_extensions import Unpack
HideyoshiNakazone commented 2025-08-19 03:23:41 +00:00 (Migrated from github.com)
Review

typing_extensions is prefered for Python3.10 compatibility

`typing_extensions` is prefered for Python3.10 compatibility
from datetime import date, datetime, time
@@ -28,6 +28,7 @@ class StringTypeParser(GenericTypeParser):
"time": time,
"date-time": datetime,
"binary": bytes,
"file-path": FilePath, # Added file-path format
}
format_pattern_mapping = {
@@ -56,4 +57,4 @@ class StringTypeParser(GenericTypeParser):
mapped_properties["json_schema_extra"] = {}
mapped_properties["json_schema_extra"]["format"] = format_type
return mapped_type, mapped_properties
return mapped_type, mapped_properties

View File

@@ -1,6 +1,6 @@
from jambo.parser import StringTypeParser
from pydantic import EmailStr, HttpUrl, IPvAnyAddress
from pydantic import EmailStr, HttpUrl, IPvAnyAddress, FilePath
from datetime import date, datetime, time
from unittest import TestCase
@@ -159,6 +159,18 @@ class TestStringTypeParser(TestCase):
type_validator["pattern"], parser.format_pattern_mapping[format_type]
)
def test_string_parser_with_file_path_format(self):
parser = StringTypeParser()
properties = {
"type": "string",
"format": "file-path",
}
type_parsing, type_validator = parser.from_properties("placeholder", properties)
self.assertEqual(type_parsing, FilePath)
def test_string_parser_with_unsupported_format(self):
parser = StringTypeParser()