Код: Выделить всё
jsonschema.RefResolver is deprecated
as of v4.18.0, in favor of the https://github.com/python-jsonschema/referencing library
Код: Выделить всё
investigation_schema_path=os.path.join(
BASE_DIR, "..", "resources", "schemas", base_schemas_dir, "core", "investigation_schema.json"
)
with open(investigation_schema_path) as fp
investigation_schema = json.load(fp)
# Code below is uses the deprecated jsonschema.RefResolver
resolver = RefResolver("file://" + investigation_schema_path, investigation_schema)
validator = Draft4Validator(investigation_schema, resolver=resolver)
validator.validate(json_to_validate)
Основываясь на прочтении https://python-jsonschema.readthedocs.i ... ferencing/, я заменил устаревший код на:
Код: Выделить всё
schema = Resource.from_contents(investigation_schema)
registry = schema @ Registry()
validator = Draft4Validator(schema, registry)
validator.validate(json_to_validate)
Тесты, которые анализируют правильный json_to_validate, по-прежнему кажутся pass.
Возможно, я неправильно понял, как использовать новую библиотеку ссылок. Есть ли у кого-нибудь предложения?
Подробнее здесь: https://stackoverflow.com/questions/797 ... s-succeeds