Skip to content

Commit cffad9f

Browse files
feat: simplify jsonschema migration to require 4.18.0+ minimum
- Update constraint to >=4.18.0,<5.0 as suggested by @aaronsteers - Remove all backward compatibility code for 4.17.x - Use referencing library exclusively with DRAFT7 default specification - Fixes CannotDetermineSpecification error for schemas without property Co-Authored-By: AJ Steers <[email protected]>
1 parent 3de3785 commit cffad9f

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

airbyte_cdk/sources/utils/schema_helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from jsonschema.exceptions import ValidationError
1515
from pydantic.v1 import BaseModel, Field
1616
from referencing import Registry, Resource
17+
from referencing.jsonschema import DRAFT7
1718

1819
from airbyte_cdk.models import ConnectorSpecification, FailureType
1920
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
@@ -71,7 +72,7 @@ def _expand_refs(schema: Any, ref_resolver: Optional[Registry] = None) -> None:
7172
:param ref_resolver: resolver to get definition from $ref, if None pass it will be instantiated
7273
"""
7374
if ref_resolver is None:
74-
resource = Resource.from_contents(schema)
75+
resource = Resource.from_contents(schema, default_specification=DRAFT7)
7576
ref_resolver = Registry().with_resource("", resource)
7677
resolver = ref_resolver.resolver()
7778

airbyte_cdk/sources/utils/transform.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from typing import Any, Callable, Dict, Generator, Mapping, Optional, cast
88

99
from jsonschema import Draft7Validator, ValidationError, Validator, validators
10-
from referencing import Registry, Resource
1110

1211
MAX_NESTING_DEPTH = 3
1312
json_to_python_simple = {

airbyte_cdk/utils/spec_schema_transformations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
from typing import Any
88

99
from referencing import Registry, Resource
10+
from referencing.jsonschema import DRAFT7
1011

1112

1213
def resolve_refs(schema: dict[str, Any]) -> dict[str, Any]:
1314
"""
1415
For spec schemas generated using Pydantic models, the resulting JSON schema can contain refs between object
1516
relationships.
1617
"""
17-
resource = Resource.from_contents(schema)
18+
resource = Resource.from_contents(schema, default_specification=DRAFT7)
1819
registry = Registry().with_resource("", resource)
1920
resolver = registry.resolver()
2021
str_schema = json.dumps(schema)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ google-cloud-secret-manager = "^2.17.0"
4343
isodate = "~0.6.1"
4444
Jinja2 = "~3.1.2"
4545
jsonref = "~0.2"
46-
jsonschema = ">=4.17.3,<5.0"
46+
jsonschema = ">=4.18.0,<5.0"
4747
packaging = "*" # Transitive dependency used directly in code
4848
referencing = ">=0.30.0" # Required for jsonschema 4.18+ RefResolver migration
4949
pandas = "2.2.3"

0 commit comments

Comments
 (0)