-
Notifications
You must be signed in to change notification settings - Fork 3.7k
.Net: OpenAPI parameter resolution mechanism - part 1 #9668
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
Merged
SergeyMenshykh
merged 8 commits into
microsoft:main
from
SergeyMenshykh:name-resolution-mechanism-part1
Nov 13, 2024
Merged
.Net: OpenAPI parameter resolution mechanism - part 1 #9668
SergeyMenshykh
merged 8 commits into
microsoft:main
from
SergeyMenshykh:name-resolution-mechanism-part1
Nov 13, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…SergeyMenshykh/semantic-kernel into name-resolution-mechanism-part1
dmytrostruk
approved these changes
Nov 12, 2024
dotnet/src/Functions/Functions.OpenApi/Extensions/RestApiOperationExtensions.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Functions/Functions.OpenApi/Extensions/RestApiOperationExtensions.cs
Show resolved
Hide resolved
dotnet/src/Functions/Functions.OpenApi/Model/RestApiOperation.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Functions/Functions.OpenApi/Model/RestApiOperation.cs
Outdated
Show resolved
Hide resolved
markwallace-microsoft
approved these changes
Nov 13, 2024
github-merge-queue bot
pushed a commit
that referenced
this pull request
Nov 14, 2024
### Motivation and Context This is the second PR to add a mechanism to transform OpenAPI documents before creating a kernel plugin from them. ### Description This PR: 1. Makes the `OpenApiDocumentParser` public, allowing for the parsing of OpenAPI documents and accessing the instance of the `RestApiSpecification` class representing the parsed document, which can be modified, by the consumer, if needed, before creating a plugin from it. Currently, it's only possible to modify argument name property of parameters and server variables. 2. Adds a few kernel extension overload methods to create and import OpenAPI document represented by the `RestApiSpecification` model class. This is the final element of the transformation mechanism that receives the specification model class instance returned by the parser and transformed by the consumer and creates an SK plugin from it. 3. Adds the `OpenApiDocumentParserOptions` class to represent existing parser options and allows adding new ones with no breaking changes. 4. Replaces the `operationsToExclude` exclusion list, which is limited to filtering out operations by operation id, with the `OperationSelectionPredicate` callback that can filter out operations based on id, method, path, and description. 5. Removes the **internal** `IOpenApiDocumentParser` unneeded interface that was not used all that time. 6. Other: XML comments + OpenAPI specification transformation sample Contributes to the issue: #4666 The first PR: #9668
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jan 6, 2025
### Motivation and Context The payload property value lookup mechanism was broken in this PR - #9668, preventing the resolution of payload property values by sanitized payload property names, leading to exceptions such as - "No argument is found for the 'customerid_[[email protected]](mailto:[email protected])' payload property." ### Description This PR fixes the issue and adds the necessary tests to ensure that the functionality won't break in the future. --------- Co-authored-by: Roger Barreto <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Today, the SK OpenAPI plugin's functionality does not support OpenAPI operations that include parameters with the same name. For example, a parameter named "id" can be used in the operation path, payload, header, and query string, each representing the ID of a different entity in those contexts. An attempt to import an OpenAPI operation containing multiple parameters with the same name will fail with the error message: "The function has two or more parameters with the same name '{parameter name}'." Therefore, the SK OpenAPI plugin needs a way to gracefully manage operations that include parameters with identical names.
Description
This PR adds the
ArgumentName
property to theRestApiPayloadProperty
andRestApiServerVariable
classes and renames theRestApiParameter.AlternativeName
property toRestApiParameter.ArgumentName
to better represent its purpose, as it was used as an argument name before. The property allows associating argument names with OpenAPI parameters and is used by theRestApiOperationRunner
to look up values for them in the arguments the function was invoked with.The next PR will allow consumers to access the OpenAPI document model and provide argument names for the "clashing" parameters.
Additionally, this PR adds functionality that allows "freezing" the classes to prevent their modification after the OpenAPI document has been parsed and imported, and its operations have become available via the
KernelFunction.Metadata.AdditionalProperties["operation"]
item.Contributes to: #4666