Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add OpenAPIConnector component, improve OpenAPI integration #8808

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

vblagoje
Copy link
Member

@vblagoje vblagoje commented Feb 4, 2025

Why:

Enables invocation of REST endpoints specified in an OpenAPI specification.

What:

  • Introduced OpenAPIConnector, a new component to invoke REST endpoints from OpenAPI specs.
  • Updated __init__.py to include OpenAPIConnector in the exports.
  • Added comprehensive unit and integration tests for OpenAPIConnector to ensure its correctness and reliability.

How can it be used:

The OpenAPIConnector can be used to perform API operations defined in an OpenAPI specification. Initialize it with an OpenAPI spec URL, file path, or string, and use it to call endpoints:

from haystack.utils import Secret
from haystack.components.connectors.openapi import OpenAPIConnector

connector = OpenAPIConnector(
    openapi_spec="https://bit.ly/serperdev_openapi",
    credentials=Secret.from_env_var("SERPERDEV_API_KEY")
)
response = connector.run(
    operation_id="search",
    parameters={"q": "Who was Nikola Tesla?"}
)

How did you test it:

Tests cover initialization, serialization, deserialization, and execution of operations to ensure component functionality.

Notes for the reviewer:

  • The test_openapi_connector.py file contains both unit and integration tests; some tests require environment variables like SERPERDEV_API_KEY or GITHUB_TOKEN to run integration tests, which are conditionally skipped if not present.
  • Pay special attention to the integration with openapi-llm and the potential requirements for the environment setup.

@github-actions github-actions bot added type:documentation Improvements on the docs topic:tests labels Feb 4, 2025
@coveralls
Copy link
Collaborator

coveralls commented Feb 4, 2025

Pull Request Test Coverage Report for Build 13138425556

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 91.322%

Totals Coverage Status
Change from base Build 13137152845: 0.02%
Covered Lines: 8977
Relevant Lines: 9830

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants