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:
@ -70,10 +76,12 @@ class SchemaDirReport:
self.errors += other_report.errors
def check_example(path, schema, example):
# URI with scheme is necessary to make RefResolver work.
# $id as a URI with scheme is necessary to make registry resolver work.
fileurl = "file://" + os.path.abspath(path)
resolver = jsonschema.RefResolver(fileurl, schema, handlers={"file": helpers.load_file_from_uri})
validator = jsonschema.Draft202012Validator(schema, resolver)
schema["$id"] = fileurl
registry = referencing.Registry(retrieve=helpers.load_resource_from_uri)
validator = jsonschema.validators.Draft202012Validator(schema, registry=registry)
validator.validate(example)
@ -128,7 +136,7 @@ def check_schema_file(schema_path):
# Check schema is valid.
try:
validator = jsonschema.Draft202012Validator
validator = jsonschema.validators.Draft202012Validator
validator.check_schema(schema)
except Exception as e:
print(f"Failed to validate JSON schema: {e}")