Skip to content

File-based CDK: fix schemas merge for nullable object types #37619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def merge_schemas(schema1: SchemaType, schema2: SchemaType) -> SchemaType:
t1 = merged_schema.get(k2)
if t1 is None:
merged_schema[k2] = t2
elif t1 == t2:
elif t1 == t2 or t2["type"] == "null":
continue
else:
merged_schema[k2] = _choose_wider_type(k2, t1, t2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@ def test_comparable_types() -> None:
id="",
),
pytest.param({"a": {"type": "invalid_type"}}, {"b": {"type": "integer"}}, None, id="invalid-type"),
pytest.param(
{"a": {"type": "object"}},
{"a": {"type": "null"}},
{"a": {"type": "object"}},
id="single-key-with-null-object-schema2"),
pytest.param(
{"a": {"type": "object"}},
{"b": {"type": "null"}},
{"a": {"type": "object"}, "b": {"type": "null"}},
id="new-key-with-null-type",
),
],
)
def test_merge_schemas(schema1: SchemaType, schema2: SchemaType, expected_result: Optional[SchemaType]) -> None:
Expand Down
Loading