Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
import guard
Browse files Browse the repository at this point in the history
  • Loading branch information
Disiok committed Jul 18, 2023
1 parent e4257a6 commit 68a51bc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion llama_hub/tools/openapi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from llama_index.readers.schema.base import Document
from llama_index.tools.tool_spec.base import BaseToolSpec
import jsonschema


class OpenAPIToolSpec(BaseToolSpec):
Expand Down Expand Up @@ -61,6 +60,13 @@ def reduce_details(details: dict) -> dict:

def dereference_openapi(openapi_doc):
"""Dereferences a Swagger/OpenAPI document by resolving all $ref pointers."""
try:
import jsonschema
except ImportError:
raise ImportError(
"The jsonschema library is required to parse OpenAPI documents. "
"Please install it with `pip install jsonschema`."
)
resolver = jsonschema.RefResolver.from_schema(openapi_doc)

def _dereference(obj):
Expand Down

0 comments on commit 68a51bc

Please sign in to comment.