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 4b6a2d5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 162 deletions.
149 changes: 0 additions & 149 deletions tools/schemapi/jsonschema-draft04.json

This file was deleted.

14 changes: 1 addition & 13 deletions 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
Expand All @@ -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)
Expand Down Expand Up @@ -144,18 +136,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 4b6a2d5

Please sign in to comment.