18
18
from pydantic import BaseModel
19
19
20
20
21
+ class AdditionalPropertiesSchema (BaseModel ):
22
+ """
23
+ Defines the value type for 'object' parameters.
24
+ """
25
+
26
+ type : str
27
+
28
+ def __get_type (self ) -> Type :
29
+ """Converts the string type to a Python type."""
30
+ if self .type == "string" :
31
+ return str
32
+ elif self .type == "integer" :
33
+ return int
34
+ elif self .type == "float" :
35
+ return float
36
+ elif self .type == "boolean" :
37
+ return bool
38
+ else :
39
+ raise ValueError (f"Unsupported schema type: { self .type } " )
40
+
41
+
21
42
class ParameterSchema (BaseModel ):
22
43
"""
23
44
Schema for a tool parameter.
@@ -29,7 +50,7 @@ class ParameterSchema(BaseModel):
29
50
description : str
30
51
authSources : Optional [list [str ]] = None
31
52
items : Optional ["ParameterSchema" ] = None
32
- additionalProperties : Optional [Union [bool , "ParameterSchema " ]] = None
53
+ additionalProperties : Optional [Union [bool , "AdditionalPropertiesSchema " ]] = None
33
54
34
55
def __get_type (self ) -> Type :
35
56
base_type : Type
@@ -46,7 +67,7 @@ def __get_type(self) -> Type:
46
67
raise ValueError ("Unexpected value: type is 'array' but items is None" )
47
68
base_type = list [self .items .__get_type ()] # type: ignore
48
69
elif self .type == "object" :
49
- if isinstance (self .additionalProperties , ParameterSchema ):
70
+ if isinstance (self .additionalProperties , AdditionalPropertiesSchema ):
50
71
value_type = self .additionalProperties .__get_type ()
51
72
base_type = dict [str , value_type ] # type: ignore
52
73
else :
0 commit comments