@@ -65,14 +65,10 @@ def test_to_gemini_schema_array_string_types(self):
6565 "nonnullable_string" : {"type" : ["string" ]},
6666 "nullable_string" : {"type" : ["string" , "null" ]},
6767 "nullable_number" : {"type" : ["null" , "integer" ]},
68- "object_nullable " : {"type" : " null" },
68+ "nullable_object " : {"type" : [ "object" , " null"] },
6969 "multi_types_nullable" : {"type" : ["string" , "null" , "integer" ]},
70+ "only_null" : {"type" : "null" },
7071 "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" ]},
7672 },
7773 }
7874 gemini_schema = _to_gemini_schema (openapi_schema )
@@ -89,32 +85,21 @@ def test_to_gemini_schema_array_string_types(self):
8985 assert gemini_schema .properties ["nullable_number" ].type == Type .INTEGER
9086 assert gemini_schema .properties ["nullable_number" ].nullable
9187
92- assert gemini_schema .properties ["object_nullable " ].type == Type .OBJECT
93- assert gemini_schema .properties ["object_nullable " ].nullable
88+ assert gemini_schema .properties ["nullable_object " ].type == Type .OBJECT
89+ assert gemini_schema .properties ["nullable_object " ].nullable
9490
95- assert gemini_schema .properties ["multi_types_nullable" ].type == Type .STRING
91+ assert gemini_schema .properties ["multi_types_nullable" ].any_of == [
92+ Schema (type = Type .STRING ),
93+ Schema (type = Type .INTEGER ),
94+ ]
9695 assert gemini_schema .properties ["multi_types_nullable" ].nullable
9796
97+ assert gemini_schema .properties ["only_null" ].type is None
98+ assert gemini_schema .properties ["only_null" ].nullable
99+
98100 assert gemini_schema .properties ["empty_default_object" ].type == Type .OBJECT
99101 assert gemini_schema .properties ["empty_default_object" ].nullable is None
100102
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-
118103 def test_to_gemini_schema_nested_objects (self ):
119104 openapi_schema = {
120105 "type" : "object" ,
@@ -159,20 +144,6 @@ def test_to_gemini_schema_nested_array(self):
159144 gemini_schema = _to_gemini_schema (openapi_schema )
160145 assert gemini_schema .items .properties ["name" ].type == Type .STRING
161146
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-
176147 def test_to_gemini_schema_any_of (self ):
177148 openapi_schema = {
178149 "anyOf" : [{"type" : "string" }, {"type" : "integer" }],
@@ -182,6 +153,14 @@ def test_to_gemini_schema_any_of(self):
182153 assert gemini_schema .any_of [0 ].type == Type .STRING
183154 assert gemini_schema .any_of [1 ].type == Type .INTEGER
184155
156+ def test_to_gemini_schema_any_of_nullable (self ):
157+ openapi_schema = {
158+ "anyOf" : [{"type" : "string" }, {"type" : "null" }],
159+ }
160+ gemini_schema = _to_gemini_schema (openapi_schema )
161+ assert gemini_schema .type == Type .STRING
162+ assert gemini_schema .nullable
163+
185164 def test_to_gemini_schema_general_list (self ):
186165 openapi_schema = {
187166 "type" : "array" ,
0 commit comments