Skip to content

Commit 1a64323

Browse files
committed
remove RefResolver
1 parent aac261c commit 1a64323

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
1010

1111
### Added
1212

13-
- Docstrings https://github.com/stac-utils/stac-validator/pull/224
13+
- Docstrings ([#224](https://github.com/stac-utils/stac-validator/pull/224))
1414

1515
### Changed
1616

1717
- Development dependencies removed from runtime dependency list
1818
([#228](https://github.com/stac-utils/stac-check/pull/109))
19+
- Remove jsonschema RefResolver ([#228](https://github.com/stac-utils/stac-check/pull/109))
1920

2021
## [v3.3.1] - 2022-12-16
2122

stac_validator/validate.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import click # type: ignore
88
import jsonschema # type: ignore
9-
from jsonschema import RefResolver
9+
from jsonschema.validators import validator_for
1010
from requests import exceptions # type: ignore
1111

1212
from .utilities import (
@@ -216,12 +216,13 @@ def custom_validator(self) -> None:
216216
jsonschema.validate(self.stac_content, schema)
217217
# in case the path to a json schema is local
218218
elif os.path.exists(self.schema):
219-
schema = fetch_and_parse_schema(self.schema)
220-
custom_abspath = os.path.abspath(self.schema)
221-
custom_dir = os.path.dirname(custom_abspath).replace("\\", "/")
222-
custom_uri = f"file:///{custom_dir}/"
223-
resolver = RefResolver(custom_uri, self.schema)
224-
jsonschema.validate(self.stac_content, schema, resolver=resolver)
219+
schema_dict = fetch_and_parse_schema(self.schema)
220+
# determine the appropriate validator class for the schema
221+
ValidatorClass = validator_for(schema_dict)
222+
validator = ValidatorClass(schema_dict)
223+
# validate the content
224+
validator.validate(self.stac_content)
225+
225226
# deal with a relative path in the schema
226227
else:
227228
file_directory = os.path.dirname(os.path.abspath(str(self.stac_file)))

0 commit comments

Comments
 (0)