Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 1 addition & 19 deletions airbyte_cdk/sources/utils/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@
#

import logging
from copy import deepcopy
from enum import Flag, auto
from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, Mapping, Optional, cast
from typing import Any, Callable, Dict, Generator, Mapping, Optional, cast

from jsonschema import Draft7Validator, ValidationError, validators
from jsonschema.protocols import Validator
from referencing import Registry, Resource
from referencing._core import Resolver
from referencing.exceptions import Unresolvable
from referencing.jsonschema import DRAFT7

from airbyte_cdk.sources.utils.schema_helpers import expand_refs

from .schema_helpers import get_ref_resolver_registry

MAX_NESTING_DEPTH = 3
json_to_python_simple = {
Expand Down Expand Up @@ -201,15 +192,6 @@ def normalizator(
validators parameter for detailed description.
:
"""
# Very first step is to expand $refs in the schema itself:
expand_refs(schema)

# Now we can expand $refs in the property value:
if isinstance(property_value, dict):
expand_refs(property_value)

# Now we can validate and normalize the values:

# Transform object and array values before running json schema type checking for each element.
# Recursively normalize every value of the "instance" sub-object,
# if "instance" is an incorrect type - skip recursive normalization of "instance"
Expand Down
15 changes: 2 additions & 13 deletions unit_tests/sources/utils/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,13 @@
"number_prop": {"type": "number"},
"int_prop": {"type": ["integer", "null"]},
"too_many_types": {"type": ["boolean", "null", "string"]},
"def": {
"type": "object",
"properties": {
"dd": {"$ref": "#/definitions/my_type"},
},
},
"array": {"type": "array", "items": {"$ref": "#/definitions/str_type"}},
"nested": {"$ref": "#/definitions/nested_type"},
"array": {"type": "array", "items": {"type": "string"}},
"nested": {"type": "object", "properties": {"a": {"type": "string"}}},
"list_of_lists": {
"type": "array",
"items": {"type": "array", "items": {"type": "string"}},
},
},
"definitions": {
"str_type": {"type": "string"},
"my_type": {"type": "string"},
"nested_type": {"type": "object", "properties": {"a": {"type": "string"}}},
},
}
VERY_NESTED_SCHEMA = {
"type": ["null", "object"],
Expand Down
Loading