Skip to content

Commit

Permalink
Add failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Oct 4, 2023
1 parent b4f9ac5 commit af86fb6
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions singer_sdk/helpers/_flattening.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,85 @@ def flatten_schema(
}
}
}
>>> nullable_leaves_schema = {
... "type": "object",
... "properties": {
... "id": {
... "type": "string"
... },
... "foo": {
... "type": ["object", "null"],
... "properties": {
... "bar": {
... "type": ["object", "null"],
... "properties": {
... "baz": {
... "type": ["object", "null"],
... "properties": {
... "qux": {
... "type": "string"
... }
... }
... }
... }
... }
... }
... }
... }
... }
>>> print(json.dumps(flatten_schema(nullable_leaves_schema, 0), indent=2))
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"foo": {
"type": [
"object",
"null"
],
"properties": {
"bar": {
"type": [
"object",
"null"
],
"properties": {
"baz": {
"type": [
"object",
"null"
],
"properties": {
"qux": {
"type": "string"
}
}
}
}
}
}
}
}
}
>>> print(json.dumps(flatten_schema(nullable_leaves_schema, 1), indent=2))
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"foo__bar": {
"type": [
"string",
"null
]
}
}
}
"""
new_schema = deepcopy(schema)
new_schema["properties"] = _flatten_schema(
Expand Down

0 comments on commit af86fb6

Please # to comment.