From c6bfac41c535a9608a67181f43864bafd3ae6d16 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 29 Jul 2018 12:30:25 +0900 Subject: [PATCH] Bypass jsonschema references resolver jsonschema's resolver doesn't work with local files on Windows. resolve_references only works with the local files (on Windows as well) but that's exactly what's needed for the case (as long as we don't have remote references, that is). Signed-off-by: Alexey Rusakov --- api/check_examples.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/api/check_examples.py b/api/check_examples.py index eb861fca..cb85cb50 100755 --- a/api/check_examples.py +++ b/api/check_examples.py @@ -44,16 +44,14 @@ except ImportError as e: def check_schema(filepath, example, schema): - # Setting the 'id' tells jsonschema where the file is so that it - # can correctly resolve relative $ref references in the schema - schema['id'] = "file://" + os.path.abspath(filepath) example = resolve_references(filepath, example) + schema = resolve_references(filepath, schema) resolver = jsonschema.RefResolver(filepath, schema, handlers={"file": load_file}) jsonschema.validate(example, schema, resolver=resolver) def check_parameter(filepath, request, parameter): - schema = parameter.get("schema") + schema = parameter.get("schema", {}) example = schema.get('example') if example and schema: