@@ -68,6 +68,11 @@ def test_to_gemini_schema_array_string_types(self):
6868 "object_nullable" : {"type" : "null" },
6969 "multi_types_nullable" : {"type" : ["string" , "null" , "integer" ]},
7070 "empty_default_object" : {},
71+ "empty_list_type" : {"type" : []},
72+ "multi_type_with_array_nullable" : {
73+ "type" : ["string" , "array" , "null" ]
74+ },
75+ "multi_type_with_array_nonnullable" : {"type" : ["integer" , "array" ]},
7176 },
7277 }
7378 gemini_schema = _to_gemini_schema (openapi_schema )
@@ -93,6 +98,23 @@ def test_to_gemini_schema_array_string_types(self):
9398 assert gemini_schema .properties ["empty_default_object" ].type == Type .OBJECT
9499 assert gemini_schema .properties ["empty_default_object" ].nullable is None
95100
101+ assert gemini_schema .properties ["empty_list_type" ].type == Type .OBJECT
102+ assert not gemini_schema .properties ["empty_list_type" ].nullable
103+
104+ assert (
105+ gemini_schema .properties ["multi_type_with_array_nullable" ].type
106+ == Type .ARRAY
107+ )
108+ assert gemini_schema .properties ["multi_type_with_array_nullable" ].nullable
109+
110+ assert (
111+ gemini_schema .properties ["multi_type_with_array_nonnullable" ].type
112+ == Type .ARRAY
113+ )
114+ assert not gemini_schema .properties [
115+ "multi_type_with_array_nonnullable"
116+ ].nullable
117+
96118 def test_to_gemini_schema_nested_objects (self ):
97119 openapi_schema = {
98120 "type" : "object" ,
@@ -137,6 +159,20 @@ def test_to_gemini_schema_nested_array(self):
137159 gemini_schema = _to_gemini_schema (openapi_schema )
138160 assert gemini_schema .items .properties ["name" ].type == Type .STRING
139161
162+ def test_to_gemini_schema_array_without_items_gets_default (self ):
163+ openapi_schema = {"type" : "array" }
164+ gemini_schema = _to_gemini_schema (openapi_schema )
165+ assert gemini_schema .type == Type .ARRAY
166+ assert not gemini_schema .nullable
167+ assert gemini_schema .items .type == Type .STRING
168+
169+ def test_to_gemini_schema_nullable_array_without_items_gets_default (self ):
170+ openapi_schema = {"type" : ["array" , "null" ]}
171+ gemini_schema = _to_gemini_schema (openapi_schema )
172+ assert gemini_schema .type == Type .ARRAY
173+ assert gemini_schema .nullable
174+ assert gemini_schema .items .type == Type .STRING
175+
140176 def test_to_gemini_schema_any_of (self ):
141177 openapi_schema = {
142178 "anyOf" : [{"type" : "string" }, {"type" : "integer" }],
@@ -533,8 +569,10 @@ def test_sanitize_schema_formats_for_gemini_nullable(self):
533569 "type" : "string" ,
534570 },
535571 "next_page_token" : {
536- "anyOf" : [{"type" : "string" }, {"type" : "null" }],
537- "default" : None ,
572+ "any_of" : [
573+ {"type" : "string" },
574+ {"type" : ["object" , "null" ]},
575+ ],
538576 "description" : (
539577 "The nextPageToken to fetch the next page of results."
540578 ),
0 commit comments