use draft-7 jsonschema validator

Change-Id: I6ae9ec146e2aa3e4f2b9875c1a9cc8edb5780b6d
This commit is contained in:
Andrey Kurilin 2024-01-10 13:04:02 +01:00
parent 0740ece61a
commit 9f93c8105b
2 changed files with 9 additions and 1 deletions

View File

@ -32,6 +32,9 @@ Changed
* `xrally/xrally docker image <https://hub.docker.com/r/xrally/xrally>`_ switched
to use python3.11-slim as a base image instead of python3.9-slim.
* Use 'draft-7' as a default jsonschema validator when there is no meta-schema
field specified at ``$schema``.
Added
~~~~~

View File

@ -30,8 +30,13 @@ class JsonSchemaValidator(validation.Validator):
"""JSON schema validator"""
def validate(self, context, config, plugin_cls, plugin_cfg):
validator = jsonschema.validators.validator_for(
plugin_cls.CONFIG_SCHEMA, default=jsonschema.Draft7Validator
)
try:
jsonschema.validate(plugin_cfg, plugin_cls.CONFIG_SCHEMA)
jsonschema.validate(
plugin_cfg, plugin_cls.CONFIG_SCHEMA, cls=validator
)
except jsonschema.ValidationError as err:
self.fail(str(err))