Fix `validate_json` scheme path (#3631)

Co-authored-by: Reinier van der Leer <github@pwuts.nl>
pull/3222/head^2
k-boikov 2023-05-01 21:06:22 +03:00 committed by GitHub
parent a5f856328d
commit 0ef6f06462
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,6 @@
"""Utilities for the json_fixes package."""
import json
import os
import re
from jsonschema import Draft7Validator
@ -35,7 +36,8 @@ def validate_json(json_object: object, schema_name: str) -> dict | None:
:param schema_name: str
:type json_object: object
"""
with open(f"autogpt/json_utils/{schema_name}.json", "r") as f:
scheme_file = os.path.join(os.path.dirname(__file__), f"{schema_name}.json")
with open(scheme_file, "r") as f:
schema = json.load(f)
validator = Draft7Validator(schema)