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

Python: OpenAPI updates to support multiple operation servers & security config #9670

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

moonbox3
Copy link
Contributor

Motivation and Context

We currently handle OpenAPI plugins via the kernel, but in a pretty simple way. The changes in this PR are allowing one to define multiple server paths for an operation as well as configure security on the operations either at the operation level or at the "global" spec level (these are included as metadata in the kernel function parameter additional_parameters dict).

Description

Adds support for OpenAPI plugin:

  • allow for multiple servers for an API operation
  • allows one to define security configuration at the spec level as well as per operation level
  • fixes a bug where the excluded_operations on the execution settings were never checked during REST API operation building
  • adds the deprecated tag to the OpenAI plugin code as it was deprecated by OpenAI and we never handled it in SK Python.
  • adds unit tests

Contribution Checklist

@moonbox3 moonbox3 requested a review from a team as a code owner November 12, 2024 20:57
@moonbox3 moonbox3 self-assigned this Nov 12, 2024
@moonbox3 moonbox3 added the openapi Issues related to the OpenAPI function importer label Nov 12, 2024
@markwallace-microsoft markwallace-microsoft added the python Pull requests for the Python Semantic Kernel label Nov 12, 2024
INFO_KEY = "info"
SECURITY_KEY = "security"
SERVER_URLS_KEY = "server-urls"
METADATA_KEY = "operation-extensions"
Copy link
Contributor

Choose a reason for hiding this comment

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

Just making sure: the value of METADATA_KEY is not metadata. And I am not seeing it being used.



@experimental_class
class RestApiOAuthFlow:
Copy link
Member

Choose a reason for hiding this comment

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

maybe use a dataclass?



@experimental_class
class RestApiOAuthFlows:
Copy link
Member

Choose a reason for hiding this comment

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

here as well

class RestApiSecurityRequirement(dict[RestApiSecurityScheme, list[str]]):
"""Represents the security requirements used by the REST API."""

def __init__(self, dictionary: dict[RestApiSecurityScheme, list[str]]):
Copy link
Member

Choose a reason for hiding this comment

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

can the parameter name be more descriptive?

@@ -29,6 +31,18 @@
logger: logging.Logger = logging.getLogger(__name__)


@experimental_class
class OperationExtensions(Enum):
Copy link
Member

Choose a reason for hiding this comment

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

should we move this into a seperate file, maybe const.py?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openapi Issues related to the OpenAPI function importer python Pull requests for the Python Semantic Kernel
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants