-
-
Notifications
You must be signed in to change notification settings - Fork 605
Description
Subject: Issue with $ref resolution after updating to the latest jsonschema version
Hi there 👋,
I hope this finds you well. I recently updated the code to the latest jsonschema version, and as part of the process, I refactored the following code:
resolver = RefResolver(file_prefix + schema_path.replace("\\", "/"), schema, store=SCHEMA_STORE)
schema_id = schema.get('$id', '')
if schema_id:
resolver.store[schema_id] = schema
# RefResolver creates a new store internally; persist it so we can use the same mappings every time
SCHEMA_STORE = resolver.store
validator = STIXValidator(schema, resolver=resolver, format_checker=Draft202012Validator.FORMAT_CHECKER)The updated code looks like:
registry = Registry().with_resource(file_prefix + schema_path.replace("\\", "/"), schema)
validator = STIXValidator(schema, registry=registry, format_checker=Draft202012Validator.FORMAT_CHECKER)
return validatorHowever, during testing, I encountered the following issue:
jsonschema.exceptions._RefResolutionError: <urlopen error [Errno 2] No such file or directory: '../common/core.json'>
The JSON schema is using $ref as follows:
json
Copy code
{
"$ref": "../common/core.json"
}After reviewing the documentation, I couldn't find any information on how to handle the file URI in this context.
Am I missing something or doing something incorrectly? Your insights and guidance would be highly appreciated.
Thank you for your time and assistance! 🙏