@@ -306,6 +306,31 @@ def test_deeply_nested_anyof_and_exclusive_minimum() -> None:
306306 assert result == expected
307307
308308
309+ def test_preserve_other_types_and_lists () -> None :
310+ """Nullable/optional types handling."""
311+ original = {
312+ "type" : "object" ,
313+ "required" : ["a" , "b" ],
314+ "properties" : {
315+ "a" : {"type" : "integer" },
316+ "b" : {"anyOf" : [{"type" : "boolean" }, {"type" : "null" }]},
317+ },
318+ }
319+ expected = {
320+ "type" : "object" ,
321+ "required" : ["a" , "b" ],
322+ "properties" : {
323+ "a" : {"type" : "integer" },
324+ "b" : {"type" : "boolean" , "nullable" : True },
325+ },
326+ }
327+ # perform the update
328+ result = recursive_update (original )
329+
330+ # non-empty dict with known content should be returned
331+ assert result == expected
332+
333+
309334def test_handles_none_values () -> None :
310335 """None values should be preserved."""
311336 original = {"key" : None }
@@ -316,3 +341,73 @@ def test_handles_none_values() -> None:
316341
317342 # non-empty dict with known content should be returned
318343 assert result == expected
344+
345+
346+ def test_handles_empty_lists () -> None :
347+ """Empty list values should be preserved."""
348+ original : dict [str , Any ] = {"key" : []}
349+ expected = original .copy ()
350+
351+ # perform the update
352+ result = recursive_update (original )
353+
354+ # non-empty dict with known content should be returned
355+ assert result == expected
356+
357+
358+ def test_handles_empty_maps () -> None :
359+ """Empty maps values should be preserved."""
360+ original : dict [str , Any ] = {"key" : {}}
361+ expected = original .copy ()
362+
363+ # perform the update
364+ result = recursive_update (original )
365+
366+ # non-empty dict with known content should be returned
367+ assert result == expected
368+
369+
370+ def test_anyof_with_additional_fields_on_first_item () -> None :
371+ """Optional (nullable) types with additional fields."""
372+ original = {
373+ "anyOf" : [
374+ {"type" : "string" , "format" : "email" , "maxLength" : 50 },
375+ {"type" : "null" },
376+ ]
377+ }
378+ expected = {
379+ "type" : "string" ,
380+ "format" : "email" ,
381+ "maxLength" : 50 ,
382+ "nullable" : True ,
383+ }
384+
385+ # perform the update
386+ result = recursive_update (original )
387+
388+ # non-empty dict with known content should be returned
389+ assert result == expected
390+
391+
392+ def test_anyof_with_additional_fields_more_items () -> None :
393+ """Optional (nullable) types with additional fields."""
394+ original = {
395+ "exclusiveMinimum" : 5 ,
396+ "anyOf" : [
397+ {"type" : "string" , "format" : "email" , "maxLength" : 50 },
398+ {"type" : "null" },
399+ ],
400+ "description" : "example" ,
401+ }
402+ expected = {
403+ "minimum" : 5 ,
404+ "type" : "string" ,
405+ "nullable" : True ,
406+ "description" : "example" ,
407+ }
408+
409+ # perform the update
410+ result = recursive_update (original )
411+
412+ # non-empty dict with known content should be returned
413+ assert result == expected
0 commit comments