Skip to content

Commit

Permalink
remove RefResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhealy1 committed Nov 17, 2023
1 parent aac261c commit 1a64323
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 8 additions & 7 deletions stac_validator/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit 1a64323

Please sign in to comment.