From 1a64323455b7ae4d21d33f287ae1772baf769d9e Mon Sep 17 00:00:00 2001 From: jonhealy1 Date: Fri, 17 Nov 2023 20:53:51 +0300 Subject: [PATCH] remove RefResolver --- CHANGELOG.md | 3 ++- stac_validator/validate.py | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41843413..8ff108ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,12 +10,13 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/) ### Added -- Docstrings https://github.com/stac-utils/stac-validator/pull/224 +- Docstrings ([#224](https://github.com/stac-utils/stac-validator/pull/224)) ### Changed - Development dependencies removed from runtime dependency list ([#228](https://github.com/stac-utils/stac-check/pull/109)) +- Remove jsonschema RefResolver ([#228](https://github.com/stac-utils/stac-check/pull/109)) ## [v3.3.1] - 2022-12-16 diff --git a/stac_validator/validate.py b/stac_validator/validate.py index 9b417716..15896fa9 100644 --- a/stac_validator/validate.py +++ b/stac_validator/validate.py @@ -6,7 +6,7 @@ import click # type: ignore import jsonschema # type: ignore -from jsonschema import RefResolver +from jsonschema.validators import validator_for from requests import exceptions # type: ignore from .utilities import ( @@ -216,12 +216,13 @@ def custom_validator(self) -> None: jsonschema.validate(self.stac_content, schema) # in case the path to a json schema is local elif os.path.exists(self.schema): - schema = fetch_and_parse_schema(self.schema) - custom_abspath = os.path.abspath(self.schema) - custom_dir = os.path.dirname(custom_abspath).replace("\\", "/") - custom_uri = f"file:///{custom_dir}/" - resolver = RefResolver(custom_uri, self.schema) - jsonschema.validate(self.stac_content, schema, resolver=resolver) + schema_dict = fetch_and_parse_schema(self.schema) + # determine the appropriate validator class for the schema + ValidatorClass = validator_for(schema_dict) + validator = ValidatorClass(schema_dict) + # validate the content + validator.validate(self.stac_content) + # deal with a relative path in the schema else: file_directory = os.path.dirname(os.path.abspath(str(self.stac_file)))