summaryrefslogtreecommitdiff
path: root/jsonschema
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2022-12-28 09:43:16 -0500
committerJulian Berman <Julian@GrayVines.com>2023-02-21 09:58:40 +0200
commitbf94d57b2b6d77cc8057be295f077435f4d4020d (patch)
tree4ee05f545dce5856c59347923a252396ad3518e3 /jsonschema
parent0ce3cef1ad37071b7bf37a919fc24498af88c831 (diff)
downloadjsonschema-bf94d57b2b6d77cc8057be295f077435f4d4020d.tar.gz
Move to retrieving schemas from the jsonschema-specifications registry.
Still will be tweaked as the referencing library's public API changes.
Diffstat (limited to 'jsonschema')
-rw-r--r--jsonschema/_utils.py18
-rw-r--r--jsonschema/schemas/draft2019-09.json42
-rw-r--r--jsonschema/schemas/draft2020-12.json58
-rw-r--r--jsonschema/schemas/draft3.json172
-rw-r--r--jsonschema/schemas/draft4.json149
-rw-r--r--jsonschema/schemas/draft6.json153
-rw-r--r--jsonschema/schemas/draft7.json166
-rw-r--r--jsonschema/schemas/vocabularies/draft2019-09/applicator56
-rw-r--r--jsonschema/schemas/vocabularies/draft2019-09/content17
-rw-r--r--jsonschema/schemas/vocabularies/draft2019-09/core57
-rw-r--r--jsonschema/schemas/vocabularies/draft2019-09/meta-data37
-rw-r--r--jsonschema/schemas/vocabularies/draft2019-09/validation98
-rw-r--r--jsonschema/schemas/vocabularies/draft2020-12/applicator48
-rw-r--r--jsonschema/schemas/vocabularies/draft2020-12/content17
-rw-r--r--jsonschema/schemas/vocabularies/draft2020-12/core51
-rw-r--r--jsonschema/schemas/vocabularies/draft2020-12/format14
-rw-r--r--jsonschema/schemas/vocabularies/draft2020-12/format-annotation14
-rw-r--r--jsonschema/schemas/vocabularies/draft2020-12/format-assertion14
-rw-r--r--jsonschema/schemas/vocabularies/draft2020-12/meta-data37
-rw-r--r--jsonschema/schemas/vocabularies/draft2020-12/unevaluated15
-rw-r--r--jsonschema/schemas/vocabularies/draft2020-12/validation98
-rw-r--r--jsonschema/validators.py37
22 files changed, 22 insertions, 1346 deletions
diff --git a/jsonschema/_utils.py b/jsonschema/_utils.py
index 418348c..c218b18 100644
--- a/jsonschema/_utils.py
+++ b/jsonschema/_utils.py
@@ -1,15 +1,7 @@
from collections.abc import Mapping, MutableMapping, Sequence
from urllib.parse import urlsplit
import itertools
-import json
import re
-import sys
-
-# The files() API was added in Python 3.9.
-if sys.version_info >= (3, 9): # pragma: no cover
- from importlib import resources
-else: # pragma: no cover
- import importlib_resources as resources # type: ignore
class URIDict(MutableMapping):
@@ -52,16 +44,6 @@ class Unset:
return "<unset>"
-def load_schema(name):
- """
- Load a schema from ./schemas/``name``.json and return it.
- """
-
- path = resources.files(__package__).joinpath(f"schemas/{name}.json")
- data = path.read_text(encoding="utf-8")
- return json.loads(data)
-
-
def format_as_index(container, indices):
"""
Construct a single string containing indexing operations for the indices.
diff --git a/jsonschema/schemas/draft2019-09.json b/jsonschema/schemas/draft2019-09.json
deleted file mode 100644
index 2248a0c..0000000
--- a/jsonschema/schemas/draft2019-09.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$id": "https://json-schema.org/draft/2019-09/schema",
- "$vocabulary": {
- "https://json-schema.org/draft/2019-09/vocab/core": true,
- "https://json-schema.org/draft/2019-09/vocab/applicator": true,
- "https://json-schema.org/draft/2019-09/vocab/validation": true,
- "https://json-schema.org/draft/2019-09/vocab/meta-data": true,
- "https://json-schema.org/draft/2019-09/vocab/format": false,
- "https://json-schema.org/draft/2019-09/vocab/content": true
- },
- "$recursiveAnchor": true,
-
- "title": "Core and Validation specifications meta-schema",
- "allOf": [
- {"$ref": "meta/core"},
- {"$ref": "meta/applicator"},
- {"$ref": "meta/validation"},
- {"$ref": "meta/meta-data"},
- {"$ref": "meta/format"},
- {"$ref": "meta/content"}
- ],
- "type": ["object", "boolean"],
- "properties": {
- "definitions": {
- "$comment": "While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",
- "type": "object",
- "additionalProperties": { "$recursiveRef": "#" },
- "default": {}
- },
- "dependencies": {
- "$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"",
- "type": "object",
- "additionalProperties": {
- "anyOf": [
- { "$recursiveRef": "#" },
- { "$ref": "meta/validation#/$defs/stringArray" }
- ]
- }
- }
- }
-}
diff --git a/jsonschema/schemas/draft2020-12.json b/jsonschema/schemas/draft2020-12.json
deleted file mode 100644
index d5e2d31..0000000
--- a/jsonschema/schemas/draft2020-12.json
+++ /dev/null
@@ -1,58 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://json-schema.org/draft/2020-12/schema",
- "$vocabulary": {
- "https://json-schema.org/draft/2020-12/vocab/core": true,
- "https://json-schema.org/draft/2020-12/vocab/applicator": true,
- "https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
- "https://json-schema.org/draft/2020-12/vocab/validation": true,
- "https://json-schema.org/draft/2020-12/vocab/meta-data": true,
- "https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
- "https://json-schema.org/draft/2020-12/vocab/content": true
- },
- "$dynamicAnchor": "meta",
-
- "title": "Core and Validation specifications meta-schema",
- "allOf": [
- {"$ref": "meta/core"},
- {"$ref": "meta/applicator"},
- {"$ref": "meta/unevaluated"},
- {"$ref": "meta/validation"},
- {"$ref": "meta/meta-data"},
- {"$ref": "meta/format-annotation"},
- {"$ref": "meta/content"}
- ],
- "type": ["object", "boolean"],
- "$comment": "This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",
- "properties": {
- "definitions": {
- "$comment": "\"definitions\" has been replaced by \"$defs\".",
- "type": "object",
- "additionalProperties": { "$dynamicRef": "#meta" },
- "deprecated": true,
- "default": {}
- },
- "dependencies": {
- "$comment": "\"dependencies\" has been split and replaced by \"dependentSchemas\" and \"dependentRequired\" in order to serve their differing semantics.",
- "type": "object",
- "additionalProperties": {
- "anyOf": [
- { "$dynamicRef": "#meta" },
- { "$ref": "meta/validation#/$defs/stringArray" }
- ]
- },
- "deprecated": true,
- "default": {}
- },
- "$recursiveAnchor": {
- "$comment": "\"$recursiveAnchor\" has been replaced by \"$dynamicAnchor\".",
- "$ref": "meta/core#/$defs/anchorString",
- "deprecated": true
- },
- "$recursiveRef": {
- "$comment": "\"$recursiveRef\" has been replaced by \"$dynamicRef\".",
- "$ref": "meta/core#/$defs/uriReferenceString",
- "deprecated": true
- }
- }
-}
diff --git a/jsonschema/schemas/draft3.json b/jsonschema/schemas/draft3.json
deleted file mode 100644
index 8b26b1f..0000000
--- a/jsonschema/schemas/draft3.json
+++ /dev/null
@@ -1,172 +0,0 @@
-{
- "$schema" : "http://json-schema.org/draft-03/schema#",
- "id" : "http://json-schema.org/draft-03/schema#",
- "type" : "object",
-
- "properties" : {
- "type" : {
- "type" : ["string", "array"],
- "items" : {
- "type" : ["string", {"$ref" : "#"}]
- },
- "uniqueItems" : true,
- "default" : "any"
- },
-
- "properties" : {
- "type" : "object",
- "additionalProperties" : {"$ref" : "#"},
- "default" : {}
- },
-
- "patternProperties" : {
- "type" : "object",
- "additionalProperties" : {"$ref" : "#"},
- "default" : {}
- },
-
- "additionalProperties" : {
- "type" : [{"$ref" : "#"}, "boolean"],
- "default" : {}
- },
-
- "items" : {
- "type" : [{"$ref" : "#"}, "array"],
- "items" : {"$ref" : "#"},
- "default" : {}
- },
-
- "additionalItems" : {
- "type" : [{"$ref" : "#"}, "boolean"],
- "default" : {}
- },
-
- "required" : {
- "type" : "boolean",
- "default" : false
- },
-
- "dependencies" : {
- "type" : "object",
- "additionalProperties" : {
- "type" : ["string", "array", {"$ref" : "#"}],
- "items" : {
- "type" : "string"
- }
- },
- "default" : {}
- },
-
- "minimum" : {
- "type" : "number"
- },
-
- "maximum" : {
- "type" : "number"
- },
-
- "exclusiveMinimum" : {
- "type" : "boolean",
- "default" : false
- },
-
- "exclusiveMaximum" : {
- "type" : "boolean",
- "default" : false
- },
-
- "minItems" : {
- "type" : "integer",
- "minimum" : 0,
- "default" : 0
- },
-
- "maxItems" : {
- "type" : "integer",
- "minimum" : 0
- },
-
- "uniqueItems" : {
- "type" : "boolean",
- "default" : false
- },
-
- "pattern" : {
- "type" : "string",
- "format" : "regex"
- },
-
- "minLength" : {
- "type" : "integer",
- "minimum" : 0,
- "default" : 0
- },
-
- "maxLength" : {
- "type" : "integer"
- },
-
- "enum" : {
- "type" : "array",
- "minItems" : 1,
- "uniqueItems" : true
- },
-
- "default" : {
- "type" : "any"
- },
-
- "title" : {
- "type" : "string"
- },
-
- "description" : {
- "type" : "string"
- },
-
- "format" : {
- "type" : "string"
- },
-
- "divisibleBy" : {
- "type" : "number",
- "minimum" : 0,
- "exclusiveMinimum" : true,
- "default" : 1
- },
-
- "disallow" : {
- "type" : ["string", "array"],
- "items" : {
- "type" : ["string", {"$ref" : "#"}]
- },
- "uniqueItems" : true
- },
-
- "extends" : {
- "type" : [{"$ref" : "#"}, "array"],
- "items" : {"$ref" : "#"},
- "default" : {}
- },
-
- "id" : {
- "type" : "string"
- },
-
- "$ref" : {
- "type" : "string"
- },
-
- "$schema" : {
- "type" : "string",
- "format" : "uri"
- }
- },
-
- "dependencies" : {
- "exclusiveMinimum" : "minimum",
- "exclusiveMaximum" : "maximum"
- },
-
- "default" : {}
-}
diff --git a/jsonschema/schemas/draft4.json b/jsonschema/schemas/draft4.json
deleted file mode 100644
index bcbb847..0000000
--- a/jsonschema/schemas/draft4.json
+++ /dev/null
@@ -1,149 +0,0 @@
-{
- "id": "http://json-schema.org/draft-04/schema#",
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Core schema meta-schema",
- "definitions": {
- "schemaArray": {
- "type": "array",
- "minItems": 1,
- "items": { "$ref": "#" }
- },
- "positiveInteger": {
- "type": "integer",
- "minimum": 0
- },
- "positiveIntegerDefault0": {
- "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
- },
- "simpleTypes": {
- "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
- },
- "stringArray": {
- "type": "array",
- "items": { "type": "string" },
- "minItems": 1,
- "uniqueItems": true
- }
- },
- "type": "object",
- "properties": {
- "id": {
- "type": "string"
- },
- "$schema": {
- "type": "string"
- },
- "title": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "default": {},
- "multipleOf": {
- "type": "number",
- "minimum": 0,
- "exclusiveMinimum": true
- },
- "maximum": {
- "type": "number"
- },
- "exclusiveMaximum": {
- "type": "boolean",
- "default": false
- },
- "minimum": {
- "type": "number"
- },
- "exclusiveMinimum": {
- "type": "boolean",
- "default": false
- },
- "maxLength": { "$ref": "#/definitions/positiveInteger" },
- "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
- "pattern": {
- "type": "string",
- "format": "regex"
- },
- "additionalItems": {
- "anyOf": [
- { "type": "boolean" },
- { "$ref": "#" }
- ],
- "default": {}
- },
- "items": {
- "anyOf": [
- { "$ref": "#" },
- { "$ref": "#/definitions/schemaArray" }
- ],
- "default": {}
- },
- "maxItems": { "$ref": "#/definitions/positiveInteger" },
- "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
- "uniqueItems": {
- "type": "boolean",
- "default": false
- },
- "maxProperties": { "$ref": "#/definitions/positiveInteger" },
- "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
- "required": { "$ref": "#/definitions/stringArray" },
- "additionalProperties": {
- "anyOf": [
- { "type": "boolean" },
- { "$ref": "#" }
- ],
- "default": {}
- },
- "definitions": {
- "type": "object",
- "additionalProperties": { "$ref": "#" },
- "default": {}
- },
- "properties": {
- "type": "object",
- "additionalProperties": { "$ref": "#" },
- "default": {}
- },
- "patternProperties": {
- "type": "object",
- "additionalProperties": { "$ref": "#" },
- "default": {}
- },
- "dependencies": {
- "type": "object",
- "additionalProperties": {
- "anyOf": [
- { "$ref": "#" },
- { "$ref": "#/definitions/stringArray" }
- ]
- }
- },
- "enum": {
- "type": "array",
- "minItems": 1,
- "uniqueItems": true
- },
- "type": {
- "anyOf": [
- { "$ref": "#/definitions/simpleTypes" },
- {
- "type": "array",
- "items": { "$ref": "#/definitions/simpleTypes" },
- "minItems": 1,
- "uniqueItems": true
- }
- ]
- },
- "format": { "type": "string" },
- "allOf": { "$ref": "#/definitions/schemaArray" },
- "anyOf": { "$ref": "#/definitions/schemaArray" },
- "oneOf": { "$ref": "#/definitions/schemaArray" },
- "not": { "$ref": "#" }
- },
- "dependencies": {
- "exclusiveMaximum": [ "maximum" ],
- "exclusiveMinimum": [ "minimum" ]
- },
- "default": {}
-}
diff --git a/jsonschema/schemas/draft6.json b/jsonschema/schemas/draft6.json
deleted file mode 100644
index a0d2bf7..0000000
--- a/jsonschema/schemas/draft6.json
+++ /dev/null
@@ -1,153 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-06/schema#",
- "$id": "http://json-schema.org/draft-06/schema#",
- "title": "Core schema meta-schema",
- "definitions": {
- "schemaArray": {
- "type": "array",
- "minItems": 1,
- "items": { "$ref": "#" }
- },
- "nonNegativeInteger": {
- "type": "integer",
- "minimum": 0
- },
- "nonNegativeIntegerDefault0": {
- "allOf": [
- { "$ref": "#/definitions/nonNegativeInteger" },
- { "default": 0 }
- ]
- },
- "simpleTypes": {
- "enum": [
- "array",
- "boolean",
- "integer",
- "null",
- "number",
- "object",
- "string"
- ]
- },
- "stringArray": {
- "type": "array",
- "items": { "type": "string" },
- "uniqueItems": true,
- "default": []
- }
- },
- "type": ["object", "boolean"],
- "properties": {
- "$id": {
- "type": "string",
- "format": "uri-reference"
- },
- "$schema": {
- "type": "string",
- "format": "uri"
- },
- "$ref": {
- "type": "string",
- "format": "uri-reference"
- },
- "title": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "default": {},
- "examples": {
- "type": "array",
- "items": {}
- },
- "multipleOf": {
- "type": "number",
- "exclusiveMinimum": 0
- },
- "maximum": {
- "type": "number"
- },
- "exclusiveMaximum": {
- "type": "number"
- },
- "minimum": {
- "type": "number"
- },
- "exclusiveMinimum": {
- "type": "number"
- },
- "maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
- "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
- "pattern": {
- "type": "string",
- "format": "regex"
- },
- "additionalItems": { "$ref": "#" },
- "items": {
- "anyOf": [
- { "$ref": "#" },
- { "$ref": "#/definitions/schemaArray" }
- ],
- "default": {}
- },
- "maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
- "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
- "uniqueItems": {
- "type": "boolean",
- "default": false
- },
- "contains": { "$ref": "#" },
- "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
- "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
- "required": { "$ref": "#/definitions/stringArray" },
- "additionalProperties": { "$ref": "#" },
- "definitions": {
- "type": "object",
- "additionalProperties": { "$ref": "#" },
- "default": {}
- },
- "properties": {
- "type": "object",
- "additionalProperties": { "$ref": "#" },
- "default": {}
- },
- "patternProperties": {
- "type": "object",
- "additionalProperties": { "$ref": "#" },
- "propertyNames": { "format": "regex" },
- "default": {}
- },
- "dependencies": {
- "type": "object",
- "additionalProperties": {
- "anyOf": [
- { "$ref": "#" },
- { "$ref": "#/definitions/stringArray" }
- ]
- }
- },
- "propertyNames": { "$ref": "#" },
- "const": {},
- "enum": {
- "type": "array"
- },
- "type": {
- "anyOf": [
- { "$ref": "#/definitions/simpleTypes" },
- {
- "type": "array",
- "items": { "$ref": "#/definitions/simpleTypes" },
- "minItems": 1,
- "uniqueItems": true
- }
- ]
- },
- "format": { "type": "string" },
- "allOf": { "$ref": "#/definitions/schemaArray" },
- "anyOf": { "$ref": "#/definitions/schemaArray" },
- "oneOf": { "$ref": "#/definitions/schemaArray" },
- "not": { "$ref": "#" }
- },
- "default": {}
-}
diff --git a/jsonschema/schemas/draft7.json b/jsonschema/schemas/draft7.json
deleted file mode 100644
index 746cde9..0000000
--- a/jsonschema/schemas/draft7.json
+++ /dev/null
@@ -1,166 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-07/schema#",
- "$id": "http://json-schema.org/draft-07/schema#",
- "title": "Core schema meta-schema",
- "definitions": {
- "schemaArray": {
- "type": "array",
- "minItems": 1,
- "items": { "$ref": "#" }
- },
- "nonNegativeInteger": {
- "type": "integer",
- "minimum": 0
- },
- "nonNegativeIntegerDefault0": {
- "allOf": [
- { "$ref": "#/definitions/nonNegativeInteger" },
- { "default": 0 }
- ]
- },
- "simpleTypes": {
- "enum": [
- "array",
- "boolean",
- "integer",
- "null",
- "number",
- "object",
- "string"
- ]
- },
- "stringArray": {
- "type": "array",
- "items": { "type": "string" },
- "uniqueItems": true,
- "default": []
- }
- },
- "type": ["object", "boolean"],
- "properties": {
- "$id": {
- "type": "string",
- "format": "uri-reference"
- },
- "$schema": {
- "type": "string",
- "format": "uri"
- },
- "$ref": {
- "type": "string",
- "format": "uri-reference"
- },
- "$comment": {
- "type": "string"
- },
- "title": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "default": true,
- "readOnly": {
- "type": "boolean",
- "default": false
- },
- "examples": {
- "type": "array",
- "items": true
- },
- "multipleOf": {
- "type": "number",
- "exclusiveMinimum": 0
- },
- "maximum": {
- "type": "number"
- },
- "exclusiveMaximum": {
- "type": "number"
- },
- "minimum": {
- "type": "number"
- },
- "exclusiveMinimum": {
- "type": "number"
- },
- "maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
- "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
- "pattern": {
- "type": "string",
- "format": "regex"
- },
- "additionalItems": { "$ref": "#" },
- "items": {
- "anyOf": [
- { "$ref": "#" },
- { "$ref": "#/definitions/schemaArray" }
- ],
- "default": true
- },
- "maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
- "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
- "uniqueItems": {
- "type": "boolean",
- "default": false
- },
- "contains": { "$ref": "#" },
- "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
- "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
- "required": { "$ref": "#/definitions/stringArray" },
- "additionalProperties": { "$ref": "#" },
- "definitions": {
- "type": "object",
- "additionalProperties": { "$ref": "#" },
- "default": {}
- },
- "properties": {
- "type": "object",
- "additionalProperties": { "$ref": "#" },
- "default": {}
- },
- "patternProperties": {
- "type": "object",
- "additionalProperties": { "$ref": "#" },
- "propertyNames": { "format": "regex" },
- "default": {}
- },
- "dependencies": {
- "type": "object",
- "additionalProperties": {
- "anyOf": [
- { "$ref": "#" },
- { "$ref": "#/definitions/stringArray" }
- ]
- }
- },
- "propertyNames": { "$ref": "#" },
- "const": true,
- "enum": {
- "type": "array",
- "items": true
- },
- "type": {
- "anyOf": [
- { "$ref": "#/definitions/simpleTypes" },
- {
- "type": "array",
- "items": { "$ref": "#/definitions/simpleTypes" },
- "minItems": 1,
- "uniqueItems": true
- }
- ]
- },
- "format": { "type": "string" },
- "contentMediaType": { "type": "string" },
- "contentEncoding": { "type": "string" },
- "if": {"$ref": "#"},
- "then": {"$ref": "#"},
- "else": {"$ref": "#"},
- "allOf": { "$ref": "#/definitions/schemaArray" },
- "anyOf": { "$ref": "#/definitions/schemaArray" },
- "oneOf": { "$ref": "#/definitions/schemaArray" },
- "not": { "$ref": "#" }
- },
- "default": true
-}
diff --git a/jsonschema/schemas/vocabularies/draft2019-09/applicator b/jsonschema/schemas/vocabularies/draft2019-09/applicator
deleted file mode 100644
index 24a1cc4..0000000
--- a/jsonschema/schemas/vocabularies/draft2019-09/applicator
+++ /dev/null
@@ -1,56 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$id": "https://json-schema.org/draft/2019-09/meta/applicator",
- "$vocabulary": {
- "https://json-schema.org/draft/2019-09/vocab/applicator": true
- },
- "$recursiveAnchor": true,
-
- "title": "Applicator vocabulary meta-schema",
- "type": ["object", "boolean"],
- "properties": {
- "additionalItems": { "$recursiveRef": "#" },
- "unevaluatedItems": { "$recursiveRef": "#" },
- "items": {
- "anyOf": [
- { "$recursiveRef": "#" },
- { "$ref": "#/$defs/schemaArray" }
- ]
- },
- "contains": { "$recursiveRef": "#" },
- "additionalProperties": { "$recursiveRef": "#" },
- "unevaluatedProperties": { "$recursiveRef": "#" },
- "properties": {
- "type": "object",
- "additionalProperties": { "$recursiveRef": "#" },
- "default": {}
- },
- "patternProperties": {
- "type": "object",
- "additionalProperties": { "$recursiveRef": "#" },
- "propertyNames": { "format": "regex" },
- "default": {}
- },
- "dependentSchemas": {
- "type": "object",
- "additionalProperties": {
- "$recursiveRef": "#"
- }
- },
- "propertyNames": { "$recursiveRef": "#" },
- "if": { "$recursiveRef": "#" },
- "then": { "$recursiveRef": "#" },
- "else": { "$recursiveRef": "#" },
- "allOf": { "$ref": "#/$defs/schemaArray" },
- "anyOf": { "$ref": "#/$defs/schemaArray" },
- "oneOf": { "$ref": "#/$defs/schemaArray" },
- "not": { "$recursiveRef": "#" }
- },
- "$defs": {
- "schemaArray": {
- "type": "array",
- "minItems": 1,
- "items": { "$recursiveRef": "#" }
- }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2019-09/content b/jsonschema/schemas/vocabularies/draft2019-09/content
deleted file mode 100644
index f6752a8..0000000
--- a/jsonschema/schemas/vocabularies/draft2019-09/content
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$id": "https://json-schema.org/draft/2019-09/meta/content",
- "$vocabulary": {
- "https://json-schema.org/draft/2019-09/vocab/content": true
- },
- "$recursiveAnchor": true,
-
- "title": "Content vocabulary meta-schema",
-
- "type": ["object", "boolean"],
- "properties": {
- "contentMediaType": { "type": "string" },
- "contentEncoding": { "type": "string" },
- "contentSchema": { "$recursiveRef": "#" }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2019-09/core b/jsonschema/schemas/vocabularies/draft2019-09/core
deleted file mode 100644
index eb708a5..0000000
--- a/jsonschema/schemas/vocabularies/draft2019-09/core
+++ /dev/null
@@ -1,57 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$id": "https://json-schema.org/draft/2019-09/meta/core",
- "$vocabulary": {
- "https://json-schema.org/draft/2019-09/vocab/core": true
- },
- "$recursiveAnchor": true,
-
- "title": "Core vocabulary meta-schema",
- "type": ["object", "boolean"],
- "properties": {
- "$id": {
- "type": "string",
- "format": "uri-reference",
- "$comment": "Non-empty fragments not allowed.",
- "pattern": "^[^#]*#?$"
- },
- "$schema": {
- "type": "string",
- "format": "uri"
- },
- "$anchor": {
- "type": "string",
- "pattern": "^[A-Za-z][-A-Za-z0-9.:_]*$"
- },
- "$ref": {
- "type": "string",
- "format": "uri-reference"
- },
- "$recursiveRef": {
- "type": "string",
- "format": "uri-reference"
- },
- "$recursiveAnchor": {
- "type": "boolean",
- "default": false
- },
- "$vocabulary": {
- "type": "object",
- "propertyNames": {
- "type": "string",
- "format": "uri"
- },
- "additionalProperties": {
- "type": "boolean"
- }
- },
- "$comment": {
- "type": "string"
- },
- "$defs": {
- "type": "object",
- "additionalProperties": { "$recursiveRef": "#" },
- "default": {}
- }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2019-09/meta-data b/jsonschema/schemas/vocabularies/draft2019-09/meta-data
deleted file mode 100644
index da04cff..0000000
--- a/jsonschema/schemas/vocabularies/draft2019-09/meta-data
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$id": "https://json-schema.org/draft/2019-09/meta/meta-data",
- "$vocabulary": {
- "https://json-schema.org/draft/2019-09/vocab/meta-data": true
- },
- "$recursiveAnchor": true,
-
- "title": "Meta-data vocabulary meta-schema",
-
- "type": ["object", "boolean"],
- "properties": {
- "title": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "default": true,
- "deprecated": {
- "type": "boolean",
- "default": false
- },
- "readOnly": {
- "type": "boolean",
- "default": false
- },
- "writeOnly": {
- "type": "boolean",
- "default": false
- },
- "examples": {
- "type": "array",
- "items": true
- }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2019-09/validation b/jsonschema/schemas/vocabularies/draft2019-09/validation
deleted file mode 100644
index 9f59677..0000000
--- a/jsonschema/schemas/vocabularies/draft2019-09/validation
+++ /dev/null
@@ -1,98 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$id": "https://json-schema.org/draft/2019-09/meta/validation",
- "$vocabulary": {
- "https://json-schema.org/draft/2019-09/vocab/validation": true
- },
- "$recursiveAnchor": true,
-
- "title": "Validation vocabulary meta-schema",
- "type": ["object", "boolean"],
- "properties": {
- "multipleOf": {
- "type": "number",
- "exclusiveMinimum": 0
- },
- "maximum": {
- "type": "number"
- },
- "exclusiveMaximum": {
- "type": "number"
- },
- "minimum": {
- "type": "number"
- },
- "exclusiveMinimum": {
- "type": "number"
- },
- "maxLength": { "$ref": "#/$defs/nonNegativeInteger" },
- "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
- "pattern": {
- "type": "string",
- "format": "regex"
- },
- "maxItems": { "$ref": "#/$defs/nonNegativeInteger" },
- "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
- "uniqueItems": {
- "type": "boolean",
- "default": false
- },
- "maxContains": { "$ref": "#/$defs/nonNegativeInteger" },
- "minContains": {
- "$ref": "#/$defs/nonNegativeInteger",
- "default": 1
- },
- "maxProperties": { "$ref": "#/$defs/nonNegativeInteger" },
- "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
- "required": { "$ref": "#/$defs/stringArray" },
- "dependentRequired": {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/$defs/stringArray"
- }
- },
- "const": true,
- "enum": {
- "type": "array",
- "items": true
- },
- "type": {
- "anyOf": [
- { "$ref": "#/$defs/simpleTypes" },
- {
- "type": "array",
- "items": { "$ref": "#/$defs/simpleTypes" },
- "minItems": 1,
- "uniqueItems": true
- }
- ]
- }
- },
- "$defs": {
- "nonNegativeInteger": {
- "type": "integer",
- "minimum": 0
- },
- "nonNegativeIntegerDefault0": {
- "$ref": "#/$defs/nonNegativeInteger",
- "default": 0
- },
- "simpleTypes": {
- "enum": [
- "array",
- "boolean",
- "integer",
- "null",
- "number",
- "object",
- "string"
- ]
- },
- "stringArray": {
- "type": "array",
- "items": { "type": "string" },
- "uniqueItems": true,
- "default": []
- }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2020-12/applicator b/jsonschema/schemas/vocabularies/draft2020-12/applicator
deleted file mode 100644
index ca69923..0000000
--- a/jsonschema/schemas/vocabularies/draft2020-12/applicator
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://json-schema.org/draft/2020-12/meta/applicator",
- "$vocabulary": {
- "https://json-schema.org/draft/2020-12/vocab/applicator": true
- },
- "$dynamicAnchor": "meta",
-
- "title": "Applicator vocabulary meta-schema",
- "type": ["object", "boolean"],
- "properties": {
- "prefixItems": { "$ref": "#/$defs/schemaArray" },
- "items": { "$dynamicRef": "#meta" },
- "contains": { "$dynamicRef": "#meta" },
- "additionalProperties": { "$dynamicRef": "#meta" },
- "properties": {
- "type": "object",
- "additionalProperties": { "$dynamicRef": "#meta" },
- "default": {}
- },
- "patternProperties": {
- "type": "object",
- "additionalProperties": { "$dynamicRef": "#meta" },
- "propertyNames": { "format": "regex" },
- "default": {}
- },
- "dependentSchemas": {
- "type": "object",
- "additionalProperties": { "$dynamicRef": "#meta" },
- "default": {}
- },
- "propertyNames": { "$dynamicRef": "#meta" },
- "if": { "$dynamicRef": "#meta" },
- "then": { "$dynamicRef": "#meta" },
- "else": { "$dynamicRef": "#meta" },
- "allOf": { "$ref": "#/$defs/schemaArray" },
- "anyOf": { "$ref": "#/$defs/schemaArray" },
- "oneOf": { "$ref": "#/$defs/schemaArray" },
- "not": { "$dynamicRef": "#meta" }
- },
- "$defs": {
- "schemaArray": {
- "type": "array",
- "minItems": 1,
- "items": { "$dynamicRef": "#meta" }
- }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2020-12/content b/jsonschema/schemas/vocabularies/draft2020-12/content
deleted file mode 100644
index 2f6e056..0000000
--- a/jsonschema/schemas/vocabularies/draft2020-12/content
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://json-schema.org/draft/2020-12/meta/content",
- "$vocabulary": {
- "https://json-schema.org/draft/2020-12/vocab/content": true
- },
- "$dynamicAnchor": "meta",
-
- "title": "Content vocabulary meta-schema",
-
- "type": ["object", "boolean"],
- "properties": {
- "contentEncoding": { "type": "string" },
- "contentMediaType": { "type": "string" },
- "contentSchema": { "$dynamicRef": "#meta" }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2020-12/core b/jsonschema/schemas/vocabularies/draft2020-12/core
deleted file mode 100644
index dfc092d..0000000
--- a/jsonschema/schemas/vocabularies/draft2020-12/core
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://json-schema.org/draft/2020-12/meta/core",
- "$vocabulary": {
- "https://json-schema.org/draft/2020-12/vocab/core": true
- },
- "$dynamicAnchor": "meta",
-
- "title": "Core vocabulary meta-schema",
- "type": ["object", "boolean"],
- "properties": {
- "$id": {
- "$ref": "#/$defs/uriReferenceString",
- "$comment": "Non-empty fragments not allowed.",
- "pattern": "^[^#]*#?$"
- },
- "$schema": { "$ref": "#/$defs/uriString" },
- "$ref": { "$ref": "#/$defs/uriReferenceString" },
- "$anchor": { "$ref": "#/$defs/anchorString" },
- "$dynamicRef": { "$ref": "#/$defs/uriReferenceString" },
- "$dynamicAnchor": { "$ref": "#/$defs/anchorString" },
- "$vocabulary": {
- "type": "object",
- "propertyNames": { "$ref": "#/$defs/uriString" },
- "additionalProperties": {
- "type": "boolean"
- }
- },
- "$comment": {
- "type": "string"
- },
- "$defs": {
- "type": "object",
- "additionalProperties": { "$dynamicRef": "#meta" }
- }
- },
- "$defs": {
- "anchorString": {
- "type": "string",
- "pattern": "^[A-Za-z_][-A-Za-z0-9._]*$"
- },
- "uriString": {
- "type": "string",
- "format": "uri"
- },
- "uriReferenceString": {
- "type": "string",
- "format": "uri-reference"
- }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2020-12/format b/jsonschema/schemas/vocabularies/draft2020-12/format
deleted file mode 100644
index 09bbfdd..0000000
--- a/jsonschema/schemas/vocabularies/draft2020-12/format
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$id": "https://json-schema.org/draft/2019-09/meta/format",
- "$vocabulary": {
- "https://json-schema.org/draft/2019-09/vocab/format": true
- },
- "$recursiveAnchor": true,
-
- "title": "Format vocabulary meta-schema",
- "type": ["object", "boolean"],
- "properties": {
- "format": { "type": "string" }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2020-12/format-annotation b/jsonschema/schemas/vocabularies/draft2020-12/format-annotation
deleted file mode 100644
index 51ef7ea..0000000
--- a/jsonschema/schemas/vocabularies/draft2020-12/format-annotation
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://json-schema.org/draft/2020-12/meta/format-annotation",
- "$vocabulary": {
- "https://json-schema.org/draft/2020-12/vocab/format-annotation": true
- },
- "$dynamicAnchor": "meta",
-
- "title": "Format vocabulary meta-schema for annotation results",
- "type": ["object", "boolean"],
- "properties": {
- "format": { "type": "string" }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2020-12/format-assertion b/jsonschema/schemas/vocabularies/draft2020-12/format-assertion
deleted file mode 100644
index 5e73fd7..0000000
--- a/jsonschema/schemas/vocabularies/draft2020-12/format-assertion
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://json-schema.org/draft/2020-12/meta/format-assertion",
- "$vocabulary": {
- "https://json-schema.org/draft/2020-12/vocab/format-assertion": true
- },
- "$dynamicAnchor": "meta",
-
- "title": "Format vocabulary meta-schema for assertion results",
- "type": ["object", "boolean"],
- "properties": {
- "format": { "type": "string" }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2020-12/meta-data b/jsonschema/schemas/vocabularies/draft2020-12/meta-data
deleted file mode 100644
index 05cbc22..0000000
--- a/jsonschema/schemas/vocabularies/draft2020-12/meta-data
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://json-schema.org/draft/2020-12/meta/meta-data",
- "$vocabulary": {
- "https://json-schema.org/draft/2020-12/vocab/meta-data": true
- },
- "$dynamicAnchor": "meta",
-
- "title": "Meta-data vocabulary meta-schema",
-
- "type": ["object", "boolean"],
- "properties": {
- "title": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "default": true,
- "deprecated": {
- "type": "boolean",
- "default": false
- },
- "readOnly": {
- "type": "boolean",
- "default": false
- },
- "writeOnly": {
- "type": "boolean",
- "default": false
- },
- "examples": {
- "type": "array",
- "items": true
- }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2020-12/unevaluated b/jsonschema/schemas/vocabularies/draft2020-12/unevaluated
deleted file mode 100644
index 5f62a3f..0000000
--- a/jsonschema/schemas/vocabularies/draft2020-12/unevaluated
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://json-schema.org/draft/2020-12/meta/unevaluated",
- "$vocabulary": {
- "https://json-schema.org/draft/2020-12/vocab/unevaluated": true
- },
- "$dynamicAnchor": "meta",
-
- "title": "Unevaluated applicator vocabulary meta-schema",
- "type": ["object", "boolean"],
- "properties": {
- "unevaluatedItems": { "$dynamicRef": "#meta" },
- "unevaluatedProperties": { "$dynamicRef": "#meta" }
- }
-}
diff --git a/jsonschema/schemas/vocabularies/draft2020-12/validation b/jsonschema/schemas/vocabularies/draft2020-12/validation
deleted file mode 100644
index 606b87b..0000000
--- a/jsonschema/schemas/vocabularies/draft2020-12/validation
+++ /dev/null
@@ -1,98 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "$id": "https://json-schema.org/draft/2020-12/meta/validation",
- "$vocabulary": {
- "https://json-schema.org/draft/2020-12/vocab/validation": true
- },
- "$dynamicAnchor": "meta",
-
- "title": "Validation vocabulary meta-schema",
- "type": ["object", "boolean"],
- "properties": {
- "type": {
- "anyOf": [
- { "$ref": "#/$defs/simpleTypes" },
- {
- "type": "array",
- "items": { "$ref": "#/$defs/simpleTypes" },
- "minItems": 1,
- "uniqueItems": true
- }
- ]
- },
- "const": true,
- "enum": {
- "type": "array",
- "items": true
- },
- "multipleOf": {
- "type": "number",
- "exclusiveMinimum": 0
- },
- "maximum": {
- "type": "number"
- },
- "exclusiveMaximum": {
- "type": "number"
- },
- "minimum": {
- "type": "number"
- },
- "exclusiveMinimum": {
- "type": "number"
- },
- "maxLength": { "$ref": "#/$defs/nonNegativeInteger" },
- "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
- "pattern": {
- "type": "string",
- "format": "regex"
- },
- "maxItems": { "$ref": "#/$defs/nonNegativeInteger" },
- "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
- "uniqueItems": {
- "type": "boolean",
- "default": false
- },
- "maxContains": { "$ref": "#/$defs/nonNegativeInteger" },
- "minContains": {
- "$ref": "#/$defs/nonNegativeInteger",
- "default": 1
- },
- "maxProperties": { "$ref": "#/$defs/nonNegativeInteger" },
- "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
- "required": { "$ref": "#/$defs/stringArray" },
- "dependentRequired": {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/$defs/stringArray"
- }
- }
- },
- "$defs": {
- "nonNegativeInteger": {
- "type": "integer",
- "minimum": 0
- },
- "nonNegativeIntegerDefault0": {
- "$ref": "#/$defs/nonNegativeInteger",
- "default": 0
- },
- "simpleTypes": {
- "enum": [
- "array",
- "boolean",
- "integer",
- "null",
- "number",
- "object",
- "string"
- ]
- },
- "stringArray": {
- "type": "array",
- "items": { "type": "string" },
- "uniqueItems": true,
- "default": []
- }
- }
-}
diff --git a/jsonschema/validators.py b/jsonschema/validators.py
index d370dc5..a976959 100644
--- a/jsonschema/validators.py
+++ b/jsonschema/validators.py
@@ -13,9 +13,9 @@ from warnings import warn
import contextlib
import json
import reprlib
-import typing
import warnings
+from jsonschema_specifications import REGISTRY as SPECIFICATIONS
from pyrsistent import m
import attr
@@ -33,7 +33,6 @@ _UNSET = _utils.Unset()
_VALIDATORS: dict[str, Validator] = {}
_META_SCHEMAS = _utils.URIDict()
-_VOCABULARIES: list[tuple[str, typing.Any]] = []
def __getattr__(name):
@@ -103,15 +102,11 @@ def _id_of(schema):
def _store_schema_list():
- if not _VOCABULARIES:
- package = _utils.resources.files(__package__)
- for version in package.joinpath("schemas", "vocabularies").iterdir():
- for path in version.iterdir():
- vocabulary = json.loads(path.read_text())
- _VOCABULARIES.append((vocabulary["$id"], vocabulary))
return [
+ (uri, each.contents) for uri, each in SPECIFICATIONS.items()
+ ] + [
(id, validator.META_SCHEMA) for id, validator in _META_SCHEMAS.items()
- ] + _VOCABULARIES
+ ]
def create(
@@ -430,7 +425,9 @@ def extend(
Draft3Validator = create(
- meta_schema=_utils.load_schema("draft3"),
+ meta_schema=SPECIFICATIONS.contents(
+ "http://json-schema.org/draft-03/schema#",
+ ),
validators={
"$ref": _validators.ref,
"additionalItems": _validators.additionalItems,
@@ -462,7 +459,9 @@ Draft3Validator = create(
)
Draft4Validator = create(
- meta_schema=_utils.load_schema("draft4"),
+ meta_schema=SPECIFICATIONS.contents(
+ "http://json-schema.org/draft-04/schema#",
+ ),
validators={
"$ref": _validators.ref,
"additionalItems": _validators.additionalItems,
@@ -499,7 +498,9 @@ Draft4Validator = create(
)
Draft6Validator = create(
- meta_schema=_utils.load_schema("draft6"),
+ meta_schema=SPECIFICATIONS.contents(
+ "http://json-schema.org/draft-06/schema#",
+ ),
validators={
"$ref": _validators.ref,
"additionalItems": _validators.additionalItems,
@@ -541,7 +542,9 @@ Draft6Validator = create(
)
Draft7Validator = create(
- meta_schema=_utils.load_schema("draft7"),
+ meta_schema=SPECIFICATIONS.contents(
+ "http://json-schema.org/draft-07/schema#",
+ ),
validators={
"$ref": _validators.ref,
"additionalItems": _validators.additionalItems,
@@ -584,7 +587,9 @@ Draft7Validator = create(
)
Draft201909Validator = create(
- meta_schema=_utils.load_schema("draft2019-09"),
+ meta_schema=SPECIFICATIONS.contents(
+ "https://json-schema.org/draft/2019-09/schema",
+ ),
validators={
"$recursiveRef": _legacy_validators.recursiveRef,
"$ref": _validators.ref,
@@ -629,7 +634,9 @@ Draft201909Validator = create(
)
Draft202012Validator = create(
- meta_schema=_utils.load_schema("draft2020-12"),
+ meta_schema=SPECIFICATIONS.contents(
+ "https://json-schema.org/draft/2020-12/schema",
+ ),
validators={
"$dynamicRef": _validators.dynamicRef,
"$ref": _validators.ref,