Rebasing 2

This commit is contained in:
Nicholas Grabar 2025-03-28 15:15:14 -07:00
parent 23b5f306da
commit b584991328

View file

@ -221,3 +221,25 @@ def test_nested_anyof_conversion():
} }
} }
assert schema == expected assert schema == expected
def test_anyof_with_excessive_nesting():
"""Test conversion with excessive nesting > max levels +1 deep."""
# generate a schema with excessive nesting
schema = {"type": "object", "properties": {}}
current = schema
for _ in range(DEFAULT_MAX_RECURSE_DEPTH + 1):
current["properties"] = {
"nested": {
"anyOf": [
{"type": "string"},
{"type": "null"}
],
"properties": {}
}
}
current = current["properties"]["nested"]
# running the conversion will raise an error
with pytest.raises(ValueError, match=f"Max depth of {DEFAULT_MAX_RECURSE_DEPTH} exceeded while processing schema. Please check the schema for excessive nesting."):
convert_anyof_null_to_nullable(schema)