Implementation:Microsoft Semantic kernel OpenApi TestPlugin DocumentV2
| Knowledge Sources | |
|---|---|
| Domains | OpenAPI, Testing, Azure_Key_Vault |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
OpenAPI v2.0 (Swagger) test specification document describing a sample Azure Key Vault connector, used as test fixture data in the Functions unit tests of the Semantic Kernel .NET SDK.
Description
This JSON file is an OpenAPI v2.0 (Swagger) specification that models a sample Azure Key Vault REST API connector. It defines endpoints for retrieving, creating, and updating secrets in Azure Key Vault. The document is used by the Functions unit test suite to validate the Semantic Kernel's OpenAPI parsing, operation extraction, and parameter handling logic for Swagger 2.0 format specifications.
The specification includes:
- GET /secrets/{secret-name} - Retrieve a specified secret from a key vault
- PUT /secrets/{secret-name} - Set a secret in a specified key vault
- Path, query, and body parameters with various types and validation rules
- Response schemas with nested object structures (attributes, id, value)
- Swagger-specific extensions such as
x-ms-visibility
Usage
This file is loaded during unit test execution to verify that the OpenAPI document parser correctly handles Swagger 2.0 format specifications. It is referenced when testing parameter extraction, operation discovery, request body parsing, and response schema interpretation in the Functions.UnitTests project. Developers working on OpenAPI integration features would use this fixture to ensure backward compatibility with Swagger 2.0 documents.
Code Reference
Source Location
- Repository: Microsoft_Semantic_kernel
- File: dotnet/src/Functions/Functions.UnitTests/OpenApi/TestPlugins/documentV2_0.json
- Lines: 1-517
Signature
{
"basePath": "/",
"consumes": [],
"definitions": {},
"host": "my-key-vault.vault.azure.net",
"info": {
"description": "A sample connector for the Azure Key Vault service.",
"title": "Azure Key Vault [Sample]",
"version": "1.0"
},
"parameters": {},
"paths": {
"/secrets/{secret-name}": {
"get": {
"description": "Get a specified secret from a given key vault.",
"operationId": "GetSecret",
"parameters": [
{
"in": "path",
"name": "secret-name",
"required": true,
"type": "string"
}
]
}
}
}
}
Import
// Load the OpenAPI v2.0 document as an embedded resource or from file in unit tests
var stream = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("documentV2_0.json");
// Or read directly from the TestPlugins directory
var json = File.ReadAllText("OpenApi/TestPlugins/documentV2_0.json");
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| secret-name | string (path) | yes | The name of the secret to retrieve or set |
| api-version | string (query) | yes | The Azure Key Vault API version (default: "7.0") |
| body | object (body) | yes (PUT) | JSON body containing the secret value and optional attributes |
Outputs
| Name | Type | Description |
|---|---|---|
| attributes | object | Secret attributes including created, enabled, recoverylevel, updated |
| id | string | The secret identifier URI |
| value | string (byte) | The secret value |
Usage Examples
Parsing the Swagger 2.0 Document in a Unit Test
// Example: Loading and parsing the Swagger 2.0 test document
using var stream = File.OpenRead("OpenApi/TestPlugins/documentV2_0.json");
var operations = await OpenApiDocumentParser.ParseAsync(stream);
// Verify the GetSecret operation was extracted
var getSecret = operations.First(op => op.Id == "GetSecret");
Assert.Equal("GET", getSecret.Method.ToString());
Assert.Contains(getSecret.Parameters, p => p.Name == "secret-name");