Add NotificationUrl to ConnectorParameters (#2717)

Based on x-ms-notification-url content/value
This commit is contained in:
Luc Genetier 2024-10-23 22:44:29 +02:00 коммит произвёл GitHub
Родитель ca42fbc708
Коммит 870eb39202
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
5 изменённых файлов: 15 добавлений и 5 удалений

Просмотреть файл

@ -17,6 +17,7 @@ namespace Microsoft.PowerFx.Connectors
public const string XMsKeyOrder = "x-ms-keyOrder";
public const string XMsKeyType = "x-ms-keyType";
public const string XMsMediaKind = "x-ms-media-kind";
public const string XMsNotificationUrl = "x-ms-notification-url";
public const string XMsNotificationContent = "x-ms-notification-content";
public const string XMsPageable = "x-ms-pageable";
public const string XMsPermission = "x-ms-permission";

Просмотреть файл

@ -351,6 +351,8 @@ namespace Microsoft.PowerFx.Connectors
internal static string GetMediaKind(this ISwaggerExtensions schema) => schema.Extensions.TryGetValue(XMsMediaKind, out IOpenApiExtension openApiExt) && openApiExt is OpenApiString openApiStr ? openApiStr.Value : null;
internal static bool? GetNotificationUrl(this ISwaggerExtensions schema) => schema.Extensions.TryGetValue(XMsNotificationUrl, out IOpenApiExtension openApiExt) && openApiExt is OpenApiBoolean openApiBool ? openApiBool.Value : null;
internal static (bool IsPresent, string Value) GetString(this IDictionary<string, IOpenApiAny> apiObj, string str) => apiObj.TryGetValue(str, out IOpenApiAny openApiAny) && openApiAny is OpenApiString openApiStr ? (true, openApiStr.Value) : (false, null);
internal static void WhenPresent(this IDictionary<string, IOpenApiAny> apiObj, string propName, Action<string> action)

Просмотреть файл

@ -28,6 +28,8 @@ namespace Microsoft.PowerFx.Connectors
public string Summary => ConnectorExtensions.Summary;
public bool SupportsDynamicIntellisense => ConnectorType.SupportsDynamicIntellisense;
public bool? NotificationUrl => ConnectorType.NotificationUrl;
internal ConnectorSchema(ISwaggerParameter openApiParameter, ISwaggerExtensions bodyExtensions, bool useHiddenTypes, ConnectorCompatibility compatibility)
{

Просмотреть файл

@ -73,6 +73,9 @@ namespace Microsoft.PowerFx.Connectors
public ConnectorPermission Permission { get; }
// Supports x-ms-notification-url
public bool? NotificationUrl { get; }
internal RecordType HiddenRecordType { get; }
// Supports x-ms-dynamic-values or -list locally
@ -124,6 +127,7 @@ namespace Microsoft.PowerFx.Connectors
Schema = schema;
Binary = schema.Format == "binary" || schema.Format == "no_format";
MediaKind = openApiParameter?.GetMediaKind().ToMediaKind() ?? (Binary ? MediaKind.File : MediaKind.NotBinary);
NotificationUrl = openApiParameter?.GetNotificationUrl();
if (schema != null)
{

Просмотреть файл

@ -1779,10 +1779,10 @@ POST https://tip1-shared-002.azure-apim.net/invoke
}
[Theory]
[InlineData(ConnectorCompatibility.SwaggerCompatibility, true, 4, "poster, location, notificationUrl, body")]
[InlineData(ConnectorCompatibility.PowerAppsCompatibility, false, 4, "poster, location, notificationUrl, body")]
[InlineData(ConnectorCompatibility.SwaggerCompatibility, false, 3, "poster, location, body")]
public void ExposeInternalParamsWithoutDefaultValueTest(ConnectorCompatibility compatibility, bool exposeInternalParamsWithoutDefaultValue, int expectedCount, string expectedParamaeters)
[InlineData(ConnectorCompatibility.SwaggerCompatibility, true, 4, "poster, location, notificationUrl, body", "<null>, <null>, True, <null>")]
[InlineData(ConnectorCompatibility.PowerAppsCompatibility, false, 4, "poster, location, notificationUrl, body", "<null>, <null>, True, <null>")]
[InlineData(ConnectorCompatibility.SwaggerCompatibility, false, 3, "poster, location, body", "<null>, <null>, <null>")]
public void ExposeInternalParamsWithoutDefaultValueTest(ConnectorCompatibility compatibility, bool exposeInternalParamsWithoutDefaultValue, int expectedCount, string expectedParameters, string expectedNotificationUrls)
{
using LoggingTestServer testConnector = new LoggingTestServer(@"Swagger\Teams.json", _output);
OpenApiDocument apiDoc = testConnector._apiDocument;
@ -1799,7 +1799,8 @@ POST https://tip1-shared-002.azure-apim.net/invoke
ConnectorFunction function = OpenApiParser.GetFunctions(connectorSettings, apiDoc).First(f => f.Name == "PostCardAndWaitForResponse");
Assert.Equal(expectedCount, function.RequiredParameters.Length);
Assert.Equal(expectedParamaeters, string.Join(", ", function.RequiredParameters.Select(rp => rp.Name)));
Assert.Equal(expectedParameters, string.Join(", ", function.RequiredParameters.Select(rp => rp.Name)));
Assert.Equal(expectedNotificationUrls, string.Join(", ", function.RequiredParameters.Select(rp => rp.NotificationUrl.HasValue ? rp.NotificationUrl.ToString() : "<null>")));
}
[Fact]