Skip to content

Commit c742f80

Browse files
committed
clean up
1 parent 98d3296 commit c742f80

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

airbyte_cdk/sources/utils/schema_helpers.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,7 @@
88
import os
99
import pkgutil
1010
from copy import deepcopy
11-
from typing import (
12-
TYPE_CHECKING,
13-
Any,
14-
ClassVar,
15-
Dict,
16-
List,
17-
Mapping,
18-
MutableMapping,
19-
Optional,
20-
Tuple,
21-
)
11+
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Mapping, MutableMapping, Tuple
2212

2313
import jsonref
2414
from jsonschema import validate
@@ -80,7 +70,7 @@ def resolve_ref_links(obj: Any) -> Any:
8070
def get_ref_resolver_registry(schema: dict[str, Any]) -> Registry:
8171
"""Get a reference resolver registry for the given schema."""
8272
resource: Resource = Resource.from_contents(
83-
contents=deepcopy(schema),
73+
contents=schema,
8474
default_specification=DRAFT7,
8575
)
8676
return Registry().with_resource(

airbyte_cdk/sources/utils/transform.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,23 +207,29 @@ def normalizator(
207207
validators parameter for detailed description.
208208
:
209209
"""
210-
# Very first step is to expand references in the schema itself
210+
# Very first step is to expand references in the schema itself:
211211
expand_refs(schema)
212+
213+
# Now we can expand references in the property value:
212214
if isinstance(property_value, dict):
213215
expand_refs(property_value)
216+
217+
# Now we can validate the entries:
218+
219+
# TODO: Delete all the below commented-out code if tests pass (simplified above)
214220
# resolver_registry: Registry = get_ref_resolver_registry(schema)
215221
# ref_resolver: Resolver = resolver_registry.resolver()
216222

217-
def resolve(subschema: dict[str, Any]) -> dict[str, Any]:
218-
# if "$ref" in subschema:
219-
# try:
220-
# resolved = ref_resolver.lookup(subschema["$ref"]).contents
221-
# except Unresolvable as e:
222-
# raise ValidationError(
223-
# f"Failed to resolve $ref '{subschema['$ref']}' from {ref_resolver!r} and schema {schema!r}: {e}"
224-
# ) from e
225-
# return cast(dict[str, Any], resolved)
226-
return subschema
223+
# def resolve(subschema: dict[str, Any]) -> dict[str, Any]:
224+
# if "$ref" in subschema:
225+
# try:
226+
# resolved = ref_resolver.lookup(subschema["$ref"]).contents
227+
# except Unresolvable as e:
228+
# raise ValidationError(
229+
# f"Failed to resolve $ref '{subschema['$ref']}' from {ref_resolver!r} and schema {schema!r}: {e}"
230+
# ) from e
231+
# return cast(dict[str, Any], resolved)
232+
# return subschema
227233

228234
# Transform object and array values before running json schema type checking for each element.
229235
# Recursively normalize every value of the "instance" sub-object,

0 commit comments

Comments
 (0)