Skip to content

Commit 97cc5f7

Browse files
authored
fix: Minor security schema fix (vblagoje#16)
* Add integration test with allowed_operations param on a huge json schema * Minor security schemas fix
1 parent 9710bb3 commit 97cc5f7

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

openapi_llm/client/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def get_authenticator(self) -> Callable[[Dict[str, Any], Dict[str, Any]], Any]:
5959
:raises ValueError: If the credentials type is not supported.
6060
"""
6161
security_schemes = self.openapi_spec.get_security_schemes()
62-
if not self.credentials:
62+
if not self.credentials or not security_schemes:
6363
return lambda security_scheme, request: None # No-op function
6464
if isinstance(self.credentials, str):
6565
return self._create_authenticator_from_credentials(

test/test_openapi_client_live_openai.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,28 @@ def test_github(self, test_files_path):
8585
service_response = service_api.invoke(response)
8686
assert "deepset" in str(service_response)
8787

88+
89+
@pytest.mark.skipif(not os.environ.get("OPENAI_API_KEY", ""), reason="OPENAI_API_KEY not set or empty")
90+
@pytest.mark.integration
91+
def test_github_json_spec(self):
92+
service_api = OpenAPIClient.from_spec(
93+
openapi_spec="https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json",
94+
allowed_operations=["search/repos"]
95+
)
96+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
97+
response = client.chat.completions.create(
98+
model="gpt-4o",
99+
messages=[
100+
{
101+
"role": "user",
102+
"content": "Invoke search/repos tool with query 'deepset-ai' and 'haystack'",
103+
}
104+
],
105+
tools=service_api.tool_definitions,
106+
)
107+
service_response = service_api.invoke(response)
108+
assert "deepset" in str(service_response)
109+
88110
@pytest.mark.skipif(not os.environ.get("FIRECRAWL_API_KEY", ""), reason="FIRECRAWL_API_KEY not set or empty")
89111
@pytest.mark.skipif(not os.environ.get("OPENAI_API_KEY", ""), reason="OPENAI_API_KEY not set or empty")
90112
@pytest.mark.integration

0 commit comments

Comments
 (0)