Skip to content

Commit

Permalink
Remove validation in SchemaInfo as not used anywhere and it reference…
Browse files Browse the repository at this point in the history
…d the wrong jsonschema draft
  • Loading branch information
binste committed Dec 25, 2022
1 parent 88ffe9f commit 8f35a96
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 160 deletions.
149 changes: 0 additions & 149 deletions tools/schemapi/jsonschema-draft04.json

This file was deleted.

12 changes: 1 addition & 11 deletions tools/schemapi/utils.py
Expand Up @@ -13,12 +13,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)
Expand Down Expand Up @@ -144,18 +138,14 @@ 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
else:
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)
Expand Down

0 comments on commit 8f35a96

Please sign in to comment.