summaryrefslogtreecommitdiff
path: root/jsonschema/validators.py
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@arm.com>2018-03-08 21:17:05 -0800
committerRob Herring <robh@kernel.org>2018-05-30 16:03:46 -0500
commitfa39b24e89ce524aec2435be0f86a046fe641a11 (patch)
tree66d3c4a85ea1bfd08d4b110a333e9db7ea59a993 /jsonschema/validators.py
parent6e4ab6d5b63d0d86b0a11f8f92da94d08db19869 (diff)
downloadjsonschema-fa39b24e89ce524aec2435be0f86a046fe641a11.tar.gz
Handle $id property for draft6 in validates()
Fix another spot where 'id' vs. '$id' needs to be handled for draft 6+. Signed-off-by: Grant Likely <grant.likely@arm.com> [robh: add testcases, re-word commit message] Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'jsonschema/validators.py')
-rw-r--r--jsonschema/validators.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/jsonschema/validators.py b/jsonschema/validators.py
index a47c3ae..a92e475 100644
--- a/jsonschema/validators.py
+++ b/jsonschema/validators.py
@@ -36,7 +36,9 @@ def validates(version):
Register the decorated validator for a ``version`` of the specification.
Registered validators and their meta schemas will be considered when
- parsing ``$schema`` properties' URIs.
+ parsing ``$schema`` properties' URIs. Meta schemas can use either
+ ``id`` or ``$id`` depending on whether they follow pre-draft6 or draft6
+ and later, respectively.
Arguments:
@@ -54,6 +56,8 @@ def validates(version):
validators[version] = cls
if u"id" in cls.META_SCHEMA:
meta_schemas[cls.META_SCHEMA[u"id"]] = cls
+ elif u"$id" in cls.META_SCHEMA:
+ meta_schemas[cls.META_SCHEMA[u"$id"]] = cls
return cls
return _validates