7
7
namespace Plugins ;
8
8
9
9
/// <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.
11
11
/// The transformations can be useful if the original OpenAPI document can't be consumed as is.
12
12
/// </summary>
13
13
public sealed class OpenApiPlugin_Customization : BaseTest
@@ -35,7 +35,8 @@ void RequestDataHandler(string requestData)
35
35
}
36
36
37
37
/// <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.
39
40
/// * Region of the API in the server variable.
40
41
/// * User ID in the path.
41
42
/// * Subscription ID in the query string.
@@ -46,13 +47,13 @@ public async Task HandleOpenApiDocumentHavingTwoParametersWithSameNameButRelated
46
47
{
47
48
OpenApiDocumentParser parser = new ( ) ;
48
49
49
- using var sr = File . OpenText ( "Resources/Plugins/ProductsPlugin/openapi.json" ) ;
50
+ using StreamReader sr = File . OpenText ( "Resources/Plugins/ProductsPlugin/openapi.json" ) ;
50
51
51
52
// Register the custom HTTP client with the stub handler
52
- var executionParameters = new OpenApiFunctionExecutionParameters ( ) { HttpClient = this . _httpClient } ;
53
+ OpenApiFunctionExecutionParameters executionParameters = new ( ) { HttpClient = this . _httpClient } ;
53
54
54
55
// Parse the OpenAPI document
55
- var specification = await parser . ParseAsync ( sr . BaseStream ) ;
56
+ RestApiSpecification specification = await parser . ParseAsync ( sr . BaseStream ) ;
56
57
57
58
// Get the 'getProductFromCart' operation
58
59
RestApiOperation getProductFromCartOperation = specification . Operations . Single ( o => o . Id == "getProductFromCart" ) ;
@@ -76,8 +77,9 @@ public async Task HandleOpenApiDocumentHavingTwoParametersWithSameNameButRelated
76
77
// Import the transformed OpenAPI plugin specification
77
78
KernelPlugin plugin = this . _kernel . ImportPluginFromOpenApi ( "Products_Plugin" , specification , new OpenApiFunctionExecutionParameters ( this . _httpClient ) ) ;
78
79
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 ( )
81
83
{
82
84
[ "region" ] = "en" ,
83
85
[ "subscriptionId" ] = "subscription-12345" ,
0 commit comments