From dd566d0dcde1a34528b9a517e3165147015776cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Thu, 28 Sep 2023 13:16:57 +0200 Subject: [PATCH] Make sure schemas in check-event-schema-examples are validated against the 2020-12 spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- scripts/check-event-schema-examples.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/check-event-schema-examples.py b/scripts/check-event-schema-examples.py index c6191321..b258ca2e 100755 --- a/scripts/check-event-schema-examples.py +++ b/scripts/check-event-schema-examples.py @@ -1,5 +1,9 @@ #!/usr/bin/env python -# + +# Validates the examples under `../data/event_schemas` against their JSON +# schemas. In the process, the JSON schemas are validated against the JSON +# Schema 2020-12 specification. + # Copyright 2016 OpenMarket Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -92,7 +96,8 @@ def check_example_file(examplepath, schemapath): print ("Checking schema for: %r %r" % (examplepath, schemapath)) try: - jsonschema.validate(example, schema, resolver=resolver) + validator = jsonschema.Draft202012Validator(schema, resolver) + validator.validate(example) except Exception as e: raise ValueError("Error validating JSON schema for %r %r" % ( examplepath, schemapath