Skip to content

Commit

Permalink
Merge pull request #165 from dbt-labs/0.2.latest--backport-jsonschema-4
Browse files Browse the repository at this point in the history
Migrate from JsonSchema 3 to JsonSchema 4 (#160)
  • Loading branch information
QMalcolm authored Oct 5, 2023
2 parents 899fcd1 + 82b5bb6 commit fdbe1c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Dependencies-20230927-234903.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Dependencies
body: Migrated jsonschema.RefResolver to referencing.Registry for jsonschema 4 compatibility
time: 2023-09-27T23:49:03.729376567-04:00
custom:
Author: 'codecae'
PR: "160"
15 changes: 9 additions & 6 deletions dbt_semantic_interfaces/parsing/schemas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from jsonschema import RefResolver
from typing import List, Tuple

from referencing import Registry, Resource
from referencing.jsonschema import DRAFT7

from dbt_semantic_interfaces.parsing.schema_validator import SchemaValidator

Expand Down Expand Up @@ -315,8 +318,8 @@
time_spine_table_configuration_schema["$id"]: time_spine_table_configuration_schema,
}


resolver = RefResolver.from_schema(schema=metric_schema, store=schema_store)
semantic_model_validator = SchemaValidator(semantic_model_schema, resolver=resolver)
metric_validator = SchemaValidator(metric_schema, resolver=resolver)
project_configuration_validator = SchemaValidator(project_configuration_schema, resolver=resolver)
resources: List[Tuple[str, Resource]] = [(str(k), DRAFT7.create_resource(v)) for k, v in schema_store.items()]
registry: Registry = Registry().with_resources(resources)
semantic_model_validator = SchemaValidator(semantic_model_schema, registry=registry)
metric_validator = SchemaValidator(metric_schema, registry=registry)
project_configuration_validator = SchemaValidator(project_configuration_schema, registry=registry)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = [
]
dependencies = [
"pydantic~=1.10",
"jsonschema~=3.0",
"jsonschema~=4.0",
"PyYAML~=6.0",
"more-itertools~=8.0",
"Jinja2~=3.0",
Expand Down

0 comments on commit fdbe1c0

Please sign in to comment.