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

Improve OpenAPITool corner cases handling (missing operationId, servers under paths, etc) #37

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

vblagoje
Copy link
Member

@vblagoje vblagoje commented Jul 17, 2024

Why:

Improves OpenAPITool's robustness in handling OpenAPI specifications with missing operationIds. Note: operationIds are not required but usually present, this fix handles openapi specs without operationIds

What:

  • Enhanced schema conversion to generate custom operationIds when they are missing
  • Having operationIds simplifies operation resolution algorithm
  • Updated type definitions and utility functions to support this change
  • Add handling of servers field under path
  • Expanded test suite to cover this new functionality

How:

  • Implemented logic to create operationIds from path and HTTP method when they are absent:
    if "operationId" not in operation_spec:
        operation_spec["operationId"] = path_to_operation_id(path, http_method)
  • Created integration tests with various API providers to ensure reliability

Testing:

  • Unit tests for new operationId generation logic
  • Integration tests with multiple LLM providers and external APIs

Notes for reviewer:

  • Focus on operationId generation logic and its consistency with OpenAPI standards

@vblagoje vblagoje changed the title Improve corner cases handling Improve OpenAPITool corner cases handling (missing operationId, servers under paths, etc) Jul 17, 2024
@coveralls
Copy link

coveralls commented Jul 17, 2024

Pull Request Test Coverage Report for Build 9991860568

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 48 of 51 (94.12%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.7%) to 90.751%

Changes Missing Coverage Covered Lines Changed/Added Lines %
haystack_experimental/components/tools/openapi/types.py 12 13 92.31%
test/components/tools/openapi/test_openapi_tool.py 12 14 85.71%
Totals Coverage Status
Change from base Build 9957950977: 0.7%
Covered Lines: 1727
Relevant Lines: 1903

💛 - Coveralls

@vblagoje vblagoje marked this pull request as ready for review July 17, 2024 12:35
@vblagoje vblagoje requested a review from a team as a code owner July 17, 2024 12:35
@vblagoje vblagoje requested review from Amnah199 and shadeMe and removed request for a team and Amnah199 July 17, 2024 12:35
@vblagoje
Copy link
Member Author

vblagoje commented Jul 17, 2024

@shadeMe I removed @Amnah199 as this PR requires a lot of context uptake that you already have
cc @anakin87 as he discovered this particular case.

Copy link
Contributor

@shadeMe shadeMe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a unit test that handles specs without operationIds.

@vblagoje
Copy link
Member Author

Added also servers resolution unit test along with operationId - 🙏 @shadeMe

@vblagoje vblagoje merged commit e5841a7 into main Jul 18, 2024
5 checks passed
@vblagoje vblagoje deleted the openapi_corner_cases_handling branch July 18, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAPITool fails to handle OpenAPI specs with servers under paths and missing operationId
3 participants