Skip to content

Commit 2a59557

Browse files
address pr review comments
1 parent 821ce01 commit 2a59557

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

dotnet/samples/Concepts/Plugins/OpenApiPlugin_Customization.cs

+9-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Plugins;
88

99
/// <summary>
10-
/// These samples different ways OpenAPI document can be transformed to change its various aspects before creating a plugin out of it.
10+
/// These samples show different ways OpenAPI document can be transformed to change its various aspects before creating a plugin out of it.
1111
/// The transformations can be useful if the original OpenAPI document can't be consumed as is.
1212
/// </summary>
1313
public sealed class OpenApiPlugin_Customization : BaseTest
@@ -35,7 +35,8 @@ void RequestDataHandler(string requestData)
3535
}
3636

3737
/// <summary>
38-
/// This sample demonstrates how to provide arguments for parameters that have the same name - 'id' but represent different entities:
38+
/// This sample demonstrates how to assign argument names to parameters and variables that have the same name.
39+
/// For example, in this sample, there are multiple parameters named 'id' in the 'getProductFromCart' operation.
3940
/// * Region of the API in the server variable.
4041
/// * User ID in the path.
4142
/// * Subscription ID in the query string.
@@ -46,13 +47,13 @@ public async Task HandleOpenApiDocumentHavingTwoParametersWithSameNameButRelated
4647
{
4748
OpenApiDocumentParser parser = new();
4849

49-
using var sr = File.OpenText("Resources/Plugins/ProductsPlugin/openapi.json");
50+
using StreamReader sr = File.OpenText("Resources/Plugins/ProductsPlugin/openapi.json");
5051

5152
// Register the custom HTTP client with the stub handler
52-
var executionParameters = new OpenApiFunctionExecutionParameters() { HttpClient = this._httpClient };
53+
OpenApiFunctionExecutionParameters executionParameters = new() { HttpClient = this._httpClient };
5354

5455
// Parse the OpenAPI document
55-
var specification = await parser.ParseAsync(sr.BaseStream);
56+
RestApiSpecification specification = await parser.ParseAsync(sr.BaseStream);
5657

5758
// Get the 'getProductFromCart' operation
5859
RestApiOperation getProductFromCartOperation = specification.Operations.Single(o => o.Id == "getProductFromCart");
@@ -76,8 +77,9 @@ public async Task HandleOpenApiDocumentHavingTwoParametersWithSameNameButRelated
7677
// Import the transformed OpenAPI plugin specification
7778
KernelPlugin plugin = this._kernel.ImportPluginFromOpenApi("Products_Plugin", specification, new OpenApiFunctionExecutionParameters(this._httpClient));
7879

79-
// Create arguments for the 'addProductToCart' operation
80-
var arguments = new KernelArguments
80+
// Create arguments for the 'addProductToCart' operation using the new argument names defined earlier.
81+
// Internally these will be mapped to the correct entity when invoking the Open API endpoint.
82+
KernelArguments arguments = new()
8183
{
8284
["region"] = "en",
8385
["subscriptionId"] = "subscription-12345",

0 commit comments

Comments
 (0)