Skip to content

Commit 6395265

Browse files
authored
fix: schema inferrer supports more than two types (#830)
1 parent e8ab340 commit 6395265

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

airbyte_cdk/utils/schema_inferrer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def _clean_any_of(self, node: InferredSchema) -> None:
120120
node[_TYPE] = [node[_TYPE], _NULL_TYPE]
121121
node.pop(_ANY_OF)
122122
# populate `type` for `anyOf` if it's not present to pass all other checks
123-
elif len(node[_ANY_OF]) == 2 and not self._null_type_in_any_of(node):
123+
elif len(node[_ANY_OF]) > 1:
124124
node[_TYPE] = [_NULL_TYPE]
125125

126126
def _clean_properties(self, node: InferredSchema) -> None:

unit_tests/utils/test_schema_inferrer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@
228228
"nested_key_2": "United Kingdom",
229229
},
230230
},
231+
{"title": "Nested_3", "type": "string", "value": "XL"},
231232
],
232233
}
233234
},
@@ -247,6 +248,7 @@
247248
"type": {"type": ["string", "null"]},
248249
"value": {
249250
"anyOf": [
251+
{"type": "string"},
250252
{"type": "array", "items": {"type": "string"}},
251253
{
252254
"type": "object",

0 commit comments

Comments
 (0)