prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Migrate to JSONschema Draft v7
  Currently we use Draft4. The library that we use supports Draft7
  
  https://json-schema.org/specification.html
  
  The idea would be:
  * to use `Draft7Validator` instead of `Draft4Validator` (nothing more...)
  * list main changes and add links in CHANGELOG (see spec release notes)
  * check compatibility with kinto-admin
  
  
  </issue>
  <code>
  [start of kinto/schema_validation.py]
  1 import colander
  2 from jsonschema import Draft4Validator, ValidationError, SchemaError, RefResolutionError, validate
  3 from pyramid.settings import asbool
  4 
  5 from kinto.core import utils
  6 from kinto.core.errors import raise_invalid
  7 from kinto.views import object_exists_or_404
  8 
  9 
  10 class JSONSchemaMapping(colander.SchemaNode):
  11     def schema_type(self, **kw):
  12         return colander.Mapping(unknown="preserve")
  13 
  14     def deserialize(self, cstruct=colander.null):
  15         # Start by deserializing a simple mapping.
  16         validated = super().deserialize(cstruct)
  17 
  18         # In case it is optional in parent schema.
  19         if not validated or validated in (colander.null, colander.drop):
  20             return validated
  21         try:
  22             check_schema(validated)
  23         except ValidationError as e:
  24             self.raise_invalid(e.message)
  25         return validated
  26 
  27 
  28 def check_schema(data):
  29     try:
  30         Draft4Validator.check_schema(data)
  31     except SchemaError as e:
  32         message = e.path.pop() + e.message
  33         raise ValidationError(message)
  34 
  35 
  36 def validate_schema(data, schema, ignore_fields=[]):
  37     required_fields = [f for f in schema.get("required", []) if f not in ignore_fields]
  38     # jsonschema doesn't accept 'required': [] yet.
  39     # See https://github.com/Julian/jsonschema/issues/337.
  40     # In the meantime, strip out 'required' if no other fields are required.
  41     if required_fields:
  42         schema = {**schema, "required": required_fields}
  43     else:
  44         schema = {f: v for f, v in schema.items() if f != "required"}
  45 
  46     data = {f: v for f, v in data.items() if f not in ignore_fields}
  47 
  48     try:
  49         validate(data, schema)
  50     except ValidationError as e:
  51         if e.path:
  52             field = e.path[-1]
  53         elif e.validator_value:
  54             field = e.validator_value[-1]
  55         else:
  56             field = e.schema_path[-1]
  57         e.field = field
  58         raise e
  59     # Raise an error here if a reference in the schema doesn't resolve.
  60     # jsonschema doesn't provide schema validation checking upon creation yet,
  61     # it must be validated against data.
  62     # See https://github.com/Julian/jsonschema/issues/399
  63     # For future support https://github.com/Julian/jsonschema/issues/346.
  64     except RefResolutionError as e:
  65         raise e
  66 
  67 
  68 def validate_from_bucket_schema_or_400(data, resource_name, request, ignore_fields=[]):
  69     """Lookup in the parent objects if a schema was defined for this resource.
  70 
  71     If the schema validation feature is enabled, if a schema is/are defined, and if the
  72     data does not validate it/them, then it raises a 400 exception.
  73     """
  74     settings = request.registry.settings
  75     schema_validation = "experimental_collection_schema_validation"
  76     # If disabled from settings, do nothing.
  77     if not asbool(settings.get(schema_validation)):
  78         return
  79 
  80     bucket_id = request.matchdict["bucket_id"]
  81     bucket_uri = utils.instance_uri(request, "bucket", id=bucket_id)
  82     buckets = request.bound_data.setdefault("buckets", {})
  83     if bucket_uri not in buckets:
  84         # Unknown yet, fetch from storage.
  85         bucket = object_exists_or_404(
  86             request, collection_id="bucket", parent_id="", object_id=bucket_id
  87         )
  88         buckets[bucket_uri] = bucket
  89 
  90     # Let's see if the bucket defines a schema for this resource.
  91     metadata_field = "{}:schema".format(resource_name)
  92     bucket = buckets[bucket_uri]
  93     if metadata_field not in bucket:
  94         return
  95 
  96     # Validate or fail with 400.
  97     schema = bucket[metadata_field]
  98     try:
  99         validate_schema(data, schema, ignore_fields=ignore_fields)
  100     except ValidationError as e:
  101         raise_invalid(request, name=e.field, description=e.message)
  102     except RefResolutionError as e:
  103         raise_invalid(request, name="schema", description=str(e))
  104
  [end of kinto/schema_validation.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/kinto/schema_validation.py b/kinto/schema_validation.py
  --- a/kinto/schema_validation.py
  +++ b/kinto/schema_validation.py
  @@ -1,5 +1,5 @@
   import colander
  -from jsonschema import Draft4Validator, ValidationError, SchemaError, RefResolutionError, validate
  +from jsonschema import Draft7Validator, ValidationError, SchemaError, RefResolutionError, validate
   from pyramid.settings import asbool
   
   from kinto.core import utils
  @@ -27,7 +27,7 @@
   
   def check_schema(data):
       try:
  -        Draft4Validator.check_schema(data)
  +        Draft7Validator.check_schema(data)
       except SchemaError as e:
           message = e.path.pop() + e.message
           raise ValidationError(message)
  
verification_info: {"golden_diff": "diff --git a/kinto/schema_validation.py b/kinto/schema_validation.py\n--- a/kinto/schema_validation.py\n+++ b/kinto/schema_validation.py\n@@ -1,5 +1,5 @@\n import colander\n-from jsonschema import Draft4Validator, ValidationError, SchemaError, RefResolutionError, validate\n+from jsonschema import Draft7Validator, ValidationError, SchemaError, RefResolutionError, validate\n from pyramid.settings import asbool\n \n from kinto.core import utils\n@@ -27,7 +27,7 @@\n \n def check_schema(data):\n     try:\n-        Draft4Validator.check_schema(data)\n+        Draft7Validator.check_schema(data)\n     except SchemaError as e:\n         message = e.path.pop() + e.message\n         raise ValidationError(message)\n", "issue": "Migrate to JSONschema Draft v7\nCurrently we use Draft4. The library that we use supports Draft7\r\n\r\nhttps://json-schema.org/specification.html\r\n\r\nThe idea would be:\r\n* to use `Draft7Validator` instead of `Draft4Validator` (nothing more...)\r\n* list main changes and add links in CHANGELOG (see spec release notes)\r\n* check compatibility with kinto-admin\r\n\n", "before_files": [{"content": "import colander\nfrom jsonschema import Draft4Validator, ValidationError, SchemaError, RefResolutionError, validate\nfrom pyramid.settings import asbool\n\nfrom kinto.core import utils\nfrom kinto.core.errors import raise_invalid\nfrom kinto.views import object_exists_or_404\n\n\nclass JSONSchemaMapping(colander.SchemaNode):\n    def schema_type(self, **kw):\n        return colander.Mapping(unknown=\"preserve\")\n\n    def deserialize(self, cstruct=colander.null):\n        # Start by deserializing a simple mapping.\n        validated = super().deserialize(cstruct)\n\n        # In case it is optional in parent schema.\n        if not validated or validated in (colander.null, colander.drop):\n            return validated\n        try:\n            check_schema(validated)\n        except ValidationError as e:\n            self.raise_invalid(e.message)\n        return validated\n\n\ndef check_schema(data):\n    try:\n        Draft4Validator.check_schema(data)\n    except SchemaError as e:\n        message = e.path.pop() + e.message\n        raise ValidationError(message)\n\n\ndef validate_schema(data, schema, ignore_fields=[]):\n    required_fields = [f for f in schema.get(\"required\", []) if f not in ignore_fields]\n    # jsonschema doesn't accept 'required': [] yet.\n    # See https://github.com/Julian/jsonschema/issues/337.\n    # In the meantime, strip out 'required' if no other fields are required.\n    if required_fields:\n        schema = {**schema, \"required\": required_fields}\n    else:\n        schema = {f: v for f, v in schema.items() if f != \"required\"}\n\n    data = {f: v for f, v in data.items() if f not in ignore_fields}\n\n    try:\n        validate(data, schema)\n    except ValidationError as e:\n        if e.path:\n            field = e.path[-1]\n        elif e.validator_value:\n            field = e.validator_value[-1]\n        else:\n            field = e.schema_path[-1]\n        e.field = field\n        raise e\n    # Raise an error here if a reference in the schema doesn't resolve.\n    # jsonschema doesn't provide schema validation checking upon creation yet,\n    # it must be validated against data.\n    # See https://github.com/Julian/jsonschema/issues/399\n    # For future support https://github.com/Julian/jsonschema/issues/346.\n    except RefResolutionError as e:\n        raise e\n\n\ndef validate_from_bucket_schema_or_400(data, resource_name, request, ignore_fields=[]):\n    \"\"\"Lookup in the parent objects if a schema was defined for this resource.\n\n    If the schema validation feature is enabled, if a schema is/are defined, and if the\n    data does not validate it/them, then it raises a 400 exception.\n    \"\"\"\n    settings = request.registry.settings\n    schema_validation = \"experimental_collection_schema_validation\"\n    # If disabled from settings, do nothing.\n    if not asbool(settings.get(schema_validation)):\n        return\n\n    bucket_id = request.matchdict[\"bucket_id\"]\n    bucket_uri = utils.instance_uri(request, \"bucket\", id=bucket_id)\n    buckets = request.bound_data.setdefault(\"buckets\", {})\n    if bucket_uri not in buckets:\n        # Unknown yet, fetch from storage.\n        bucket = object_exists_or_404(\n            request, collection_id=\"bucket\", parent_id=\"\", object_id=bucket_id\n        )\n        buckets[bucket_uri] = bucket\n\n    # Let's see if the bucket defines a schema for this resource.\n    metadata_field = \"{}:schema\".format(resource_name)\n    bucket = buckets[bucket_uri]\n    if metadata_field not in bucket:\n        return\n\n    # Validate or fail with 400.\n    schema = bucket[metadata_field]\n    try:\n        validate_schema(data, schema, ignore_fields=ignore_fields)\n    except ValidationError as e:\n        raise_invalid(request, name=e.field, description=e.message)\n    except RefResolutionError as e:\n        raise_invalid(request, name=\"schema\", description=str(e))\n", "path": "kinto/schema_validation.py"}]}