Skip to content

Commit 59e4163

Browse files
authored
fix: remove references resolution from normalization (#812)
1 parent 6ea924a commit 59e4163

File tree

2 files changed

+3
-32
lines changed

2 files changed

+3
-32
lines changed

airbyte_cdk/sources/utils/transform.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,11 @@
33
#
44

55
import logging
6-
from copy import deepcopy
76
from enum import Flag, auto
8-
from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, Mapping, Optional, cast
7+
from typing import Any, Callable, Dict, Generator, Mapping, Optional, cast
98

109
from jsonschema import Draft7Validator, ValidationError, validators
1110
from jsonschema.protocols import Validator
12-
from referencing import Registry, Resource
13-
from referencing._core import Resolver
14-
from referencing.exceptions import Unresolvable
15-
from referencing.jsonschema import DRAFT7
16-
17-
from airbyte_cdk.sources.utils.schema_helpers import expand_refs
18-
19-
from .schema_helpers import get_ref_resolver_registry
2011

2112
MAX_NESTING_DEPTH = 3
2213
json_to_python_simple = {
@@ -201,15 +192,6 @@ def normalizator(
201192
validators parameter for detailed description.
202193
:
203194
"""
204-
# Very first step is to expand $refs in the schema itself:
205-
expand_refs(schema)
206-
207-
# Now we can expand $refs in the property value:
208-
if isinstance(property_value, dict):
209-
expand_refs(property_value)
210-
211-
# Now we can validate and normalize the values:
212-
213195
# Transform object and array values before running json schema type checking for each element.
214196
# Recursively normalize every value of the "instance" sub-object,
215197
# if "instance" is an incorrect type - skip recursive normalization of "instance"

unit_tests/sources/utils/test_transform.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,13 @@
1818
"number_prop": {"type": "number"},
1919
"int_prop": {"type": ["integer", "null"]},
2020
"too_many_types": {"type": ["boolean", "null", "string"]},
21-
"def": {
22-
"type": "object",
23-
"properties": {
24-
"dd": {"$ref": "#/definitions/my_type"},
25-
},
26-
},
27-
"array": {"type": "array", "items": {"$ref": "#/definitions/str_type"}},
28-
"nested": {"$ref": "#/definitions/nested_type"},
21+
"array": {"type": "array", "items": {"type": "string"}},
22+
"nested": {"type": "object", "properties": {"a": {"type": "string"}}},
2923
"list_of_lists": {
3024
"type": "array",
3125
"items": {"type": "array", "items": {"type": "string"}},
3226
},
3327
},
34-
"definitions": {
35-
"str_type": {"type": "string"},
36-
"my_type": {"type": "string"},
37-
"nested_type": {"type": "object", "properties": {"a": {"type": "string"}}},
38-
},
3928
}
4029
VERY_NESTED_SCHEMA = {
4130
"type": ["null", "object"],

0 commit comments

Comments
 (0)