From 95cf20636e181c4da66fdfb0b44dc1187aa7fe44 Mon Sep 17 00:00:00 2001 From: Stefan Binder Date: Sun, 25 Dec 2022 10:43:07 +0000 Subject: [PATCH] Remove validation in SchemaInfo as not used anywhere and it referenced the wrong jsonschema draft --- tools/schemapi/jsonschema-draft04.json | 149 ------------------------- tools/schemapi/utils.py | 14 +-- 2 files changed, 1 insertion(+), 162 deletions(-) delete mode 100644 tools/schemapi/jsonschema-draft04.json diff --git a/tools/schemapi/jsonschema-draft04.json b/tools/schemapi/jsonschema-draft04.json deleted file mode 100644 index bcbb84743..000000000 --- a/tools/schemapi/jsonschema-draft04.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/tools/schemapi/utils.py b/tools/schemapi/utils.py index d0b149f3f..5a73c96cd 100644 --- a/tools/schemapi/utils.py +++ b/tools/schemapi/utils.py @@ -1,8 +1,6 @@ """Utilities for working with schemas""" -import json import keyword -import pkgutil import re import textwrap import urllib @@ -13,12 +11,6 @@ EXCLUDE_KEYS = ("definitions", "title", "description", "$schema", "id") -def load_metaschema(): - schema = pkgutil.get_data("schemapi", "jsonschema-draft04.json") - schema = schema.decode() - return json.loads(schema) - - def resolve_references(schema, root=None): """Resolve References within a JSON schema""" resolver = jsonschema.RefResolver.from_schema(root or schema) @@ -144,7 +136,7 @@ def values(self): class SchemaInfo(object): """A wrapper for inspecting a JSON schema""" - def __init__(self, schema, rootschema=None, validate=False): + def __init__(self, schema, rootschema=None): if hasattr(schema, "_schema"): if hasattr(schema, "_rootschema"): schema, rootschema = schema._schema, schema._rootschema @@ -152,10 +144,6 @@ def __init__(self, schema, rootschema=None, validate=False): schema, rootschema = schema._schema, schema._schema elif not rootschema: rootschema = schema - if validate: - metaschema = load_metaschema() - jsonschema.validate(schema, metaschema) - jsonschema.validate(rootschema, metaschema) self.raw_schema = schema self.rootschema = rootschema self.schema = resolve_references(schema, rootschema)