Upgrade CI scripts dependencies (#1786)

Will allow us to benefit from future fixes in JSON Schema validation.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
Kévin Commaille 2024-04-16 18:59:12 +02:00 committed by GitHub
parent becc667672
commit a81b720151
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 51 additions and 13 deletions

View file

@ -42,6 +42,12 @@ except ImportError as e:
import_error("jsonschema", "jsonschema", "jsonschema", e)
raise
try:
import referencing
except ImportError as e:
import_error("referencing", "referencing", "referencing", e)
raise
try:
import yaml
except ImportError as e:
@ -56,13 +62,14 @@ def check_example_file(examplepath, schemapath):
with open(schemapath) as f:
schema = yaml.safe_load(f)
# $id as a URI with scheme is necessary to make registry resolver work.
fileurl = "file://" + os.path.abspath(schemapath)
schema["id"] = fileurl
resolver = jsonschema.RefResolver(fileurl, schema, handlers={"file": helpers.load_file_from_uri})
schema["$id"] = fileurl
print ("Checking schema for: %r %r" % (examplepath, schemapath))
try:
validator = jsonschema.Draft202012Validator(schema, resolver)
registry = referencing.Registry(retrieve=helpers.load_resource_from_uri)
validator = jsonschema.validators.Draft202012Validator(schema, registry=registry)
validator.validate(example)
except Exception as e:
raise ValueError("Error validating JSON schema for %r %r" % (