def _load_jsonschema_validator(cls, schema): if isinstance(schema, six.string_types): schema = get_schema_from(schema) if not isinstance(schema, dict): raise NotConfigured( "Invalid schema, jsonschemas must be defined as:\n" "- a python dict.\n" "- an object path to a python dict.\n" "- an object path to a JSON string.\n" "- a path to a JSON file.") return JSONSchemaValidator(schema)
def _load_jsonschema_validator(cls, schema): if isinstance(schema, six.string_types): if schema.endswith('.json'): with open(schema, 'r') as f: schema = json.load(f) else: schema = load_object(schema) if isinstance(schema, six.string_types): schema = json.loads(schema) if not isinstance(schema, dict): raise NotConfigured('Invalid schema, jsonschemas must be defined as:\n' '- a python dict.\n' '- an object path to a python dict.\n' '- an object path to a JSON string.\n' '- a path to a JSON file.') return JSONSchemaValidator(schema)