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).
@@ -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:
