@@ -66,9 +66,15 @@ def test_to_gemini_schema_array_string_types(self):
6666 "nullable_string" : {"type" : ["string" , "null" ]},
6767 "nullable_number" : {"type" : ["null" , "integer" ]},
6868 "nullable_object" : {"type" : ["object" , "null" ]},
69+ "object_nullable" : {"type" : "null" },
6970 "multi_types_nullable" : {"type" : ["string" , "null" , "integer" ]},
7071 "only_null" : {"type" : "null" },
7172 "empty_default_object" : {},
73+ "empty_list_type" : {"type" : []},
74+ "multi_type_with_array_nullable" : {
75+ "type" : ["string" , "array" , "null" ]
76+ },
77+ "multi_type_with_array_nonnullable" : {"type" : ["integer" , "array" ]},
7278 },
7379 }
7480 gemini_schema = _to_gemini_schema (openapi_schema )
@@ -88,18 +94,38 @@ def test_to_gemini_schema_array_string_types(self):
8894 assert gemini_schema .properties ["nullable_object" ].type == Type .OBJECT
8995 assert gemini_schema .properties ["nullable_object" ].nullable
9096
91- assert gemini_schema .properties ["multi_types_nullable " ].any_of == [
92- Schema ( type = Type . STRING ),
93- Schema ( type = Type . INTEGER ),
94- ]
97+ assert gemini_schema .properties ["object_nullable " ].type == Type . OBJECT
98+ assert gemini_schema . properties [ "object_nullable" ]. nullable
99+
100+ assert gemini_schema . properties [ "multi_types_nullable" ]. type == Type . STRING
95101 assert gemini_schema .properties ["multi_types_nullable" ].nullable
96102
97- assert gemini_schema .properties ["only_null" ].type is None
103+ assert gemini_schema .properties ["only_null" ].type == Type . OBJECT
98104 assert gemini_schema .properties ["only_null" ].nullable
99105
106+ assert gemini_schema .properties ["multi_types_nullable" ].type == Type .STRING
107+ assert gemini_schema .properties ["multi_types_nullable" ].nullable
108+
100109 assert gemini_schema .properties ["empty_default_object" ].type == Type .OBJECT
101110 assert gemini_schema .properties ["empty_default_object" ].nullable is None
102111
112+ assert gemini_schema .properties ["empty_list_type" ].type == Type .OBJECT
113+ assert not gemini_schema .properties ["empty_list_type" ].nullable
114+
115+ assert (
116+ gemini_schema .properties ["multi_type_with_array_nullable" ].type
117+ == Type .ARRAY
118+ )
119+ assert gemini_schema .properties ["multi_type_with_array_nullable" ].nullable
120+
121+ assert (
122+ gemini_schema .properties ["multi_type_with_array_nonnullable" ].type
123+ == Type .ARRAY
124+ )
125+ assert not gemini_schema .properties [
126+ "multi_type_with_array_nonnullable"
127+ ].nullable
128+
103129 def test_to_gemini_schema_nested_objects (self ):
104130 openapi_schema = {
105131 "type" : "object" ,
@@ -144,6 +170,20 @@ def test_to_gemini_schema_nested_array(self):
144170 gemini_schema = _to_gemini_schema (openapi_schema )
145171 assert gemini_schema .items .properties ["name" ].type == Type .STRING
146172
173+ def test_to_gemini_schema_array_without_items_gets_default (self ):
174+ openapi_schema = {"type" : "array" }
175+ gemini_schema = _to_gemini_schema (openapi_schema )
176+ assert gemini_schema .type == Type .ARRAY
177+ assert not gemini_schema .nullable
178+ assert gemini_schema .items .type == Type .STRING
179+
180+ def test_to_gemini_schema_nullable_array_without_items_gets_default (self ):
181+ openapi_schema = {"type" : ["array" , "null" ]}
182+ gemini_schema = _to_gemini_schema (openapi_schema )
183+ assert gemini_schema .type == Type .ARRAY
184+ assert gemini_schema .nullable
185+ assert gemini_schema .items .type == Type .STRING
186+
147187 def test_to_gemini_schema_any_of (self ):
148188 openapi_schema = {
149189 "anyOf" : [{"type" : "string" }, {"type" : "integer" }],
@@ -200,7 +240,7 @@ def test_to_gemini_schema_nested_dict(self):
200240 },
201241 }
202242 gemini_schema = _to_gemini_schema (openapi_schema )
203- # Since metadata is neither properties nor item, it will call to_gemini_schema recursively.
243+ # Since metadata is not properties nor item, it will call to_gemini_schema recursively.
204244 assert isinstance (gemini_schema .properties ["metadata" ], Schema )
205245 assert (
206246 gemini_schema .properties ["metadata" ].type == Type .OBJECT
@@ -544,7 +584,7 @@ def test_sanitize_schema_formats_for_gemini_nullable(self):
544584 "properties" : {
545585 "case_id" : {
546586 "description" : "The ID of the case." ,
547- "title" : "Case ID " ,
587+ "title" : "Case Id " ,
548588 "type" : "string" ,
549589 },
550590 "next_page_token" : {
@@ -567,7 +607,7 @@ def test_sanitize_schema_formats_for_gemini_nullable(self):
567607 "properties" : {
568608 "case_id" : {
569609 "description" : "The ID of the case." ,
570- "title" : "Case ID " ,
610+ "title" : "Case Id " ,
571611 "type" : "string" ,
572612 },
573613 "next_page_token" : {
0 commit comments