Fix DisplayName logic in connectors (#2329)

This commit is contained in:
Luc Genetier 2024-04-18 17:55:54 +02:00 коммит произвёл GitHub
Родитель 1527d7e836
Коммит 008e6fd575
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 42 добавлений и 29 удалений

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

@ -568,7 +568,20 @@ namespace Microsoft.PowerFx.Connectors
}
string propLogicalName = kv.Key;
string propDisplayName = GetDisplayName(string.IsNullOrWhiteSpace(kv.Value.Title) ? kv.Key : kv.Value.Title);
string propDisplayName = kv.Value.Title;
if (string.IsNullOrEmpty(propDisplayName))
{
propDisplayName = kv.Value.GetSummary();
}
if (string.IsNullOrEmpty(propDisplayName))
{
propDisplayName = kv.Key;
}
propDisplayName = GetDisplayName(propDisplayName);
string schemaIdentifier = GetUniqueIdentifier(kv.Value);
if (schemaIdentifier.StartsWith("R:", StringComparison.Ordinal) && settings.Chain.Contains(schemaIdentifier))

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

@ -24,16 +24,13 @@ namespace Microsoft.PowerFx.Connectors
{
// "name"
public string Name { get; internal set; }
// "title"
// "x-ms-summary" or "title"
public string DisplayName { get; }
// "description"
public string Description { get; }
// "x-ms-summary"
public string Summary { get; }
// "required"
public bool IsRequired { get; internal set; }
@ -108,8 +105,11 @@ namespace Microsoft.PowerFx.Connectors
if (schema != null)
{
Description = schema.Description;
DisplayName = schema.Title;
Summary = schema.GetSummary();
string summary = schema.GetSummary();
string title = schema.Title;
DisplayName = string.IsNullOrEmpty(title) ? summary : title;
ExplicitInput = schema.GetExplicitInput();
Fields = Array.Empty<ConnectorType>();

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

@ -59,42 +59,42 @@ namespace Microsoft.PowerFx.Connectors.Tests
/* APIM body */ "",
/* response files */ "Response_O365Groups_ListGroups_01.json",
"Response_O365Groups_ListGroups_02.json")]
[InlineData(
@"First(Office365Groups.ListGroups({ '$filter': ""id eq '202a2963-7e7d-4dc6-8aca-a58a2f3a9d53'"" }).value).description",
"TestProject9Aug",
"GET:/apim/office365groups/380cef7ddacd49d2bdb5b747184c7d8a/v1.0/groups?$filter=id+eq+%27202a2963-7e7d-4dc6-8aca-a58a2f3a9d53%27",
"",
"Response_O365Groups_ListGroupsWithFilter.json")]
[InlineData(
@"First(Office365Groups.ListGroupMembers(GUID(""202a2963-7e7d-4dc6-8aca-a58a2f3a9d53"")).value).displayName",
"aurorauser09",
"GET:/apim/office365groups/380cef7ddacd49d2bdb5b747184c7d8a/v1.0/groups/202a2963-7e7d-4dc6-8aca-a58a2f3a9d53/members",
"",
"Response_O365Groups_ListGroupMembers.json")]
[InlineData(
@"First(Office365Groups.ListOwnedGroups().value).displayName",
"11111",
"GET:/apim/office365groups/380cef7ddacd49d2bdb5b747184c7d8a/v1.0/me/memberOf/$/microsoft.graph.group",
"",
"Response_O365Groups_ListOwnedGroups.json")]
[InlineData(
@"First(Office365Groups.ListOwnedGroupsV2().value).mailNickname",
"11111",
"GET:/apim/office365groups/380cef7ddacd49d2bdb5b747184c7d8a/v1.0/me/ownedObjects/$/microsoft.graph.group",
"",
"Response_O365Groups_ListOwnedGroupsV2.json")]
[InlineData(
@"First(Office365Groups.ListOwnedGroupsV3().value).mail",
"11111@capintegration01.onmicrosoft.com",
"GET:/apim/office365groups/380cef7ddacd49d2bdb5b747184c7d8a/v2/v1.0/me/memberOf/$/microsoft.graph.group",
"",
"Response_O365Groups_ListOwnedGroupsV3.json")]
[InlineData(
@"Office365Groups.AddMemberToGroup(GUID(""202a2963-7e7d-4dc6-8aca-a58a2f3a9d53""), ""aurorauser09@capintegration01.onmicrosoft.com"")",
"ERR:Office365Groups.AddMemberToGroup failed: The server returned an HTTP error with code 400|One or more added object references already exist for the following modified properties: 'members'.",
@ -103,7 +103,7 @@ namespace Microsoft.PowerFx.Connectors.Tests
"400:Response_O365Groups_AddMemberToGroup.json")]
// In start and end, timeZone is NOT mandatory (even if PA requires it)
[InlineData(
[InlineData(
@"Office365Groups.CreateCalendarEvent(GUID(""202a2963-7e7d-4dc6-8aca-a58a2f3a9d53""), ""Event1"", { dateTime: Now() }, { dateTime: Now(), timeZone: ""UTC"" }).subject",
"Event1",
"POST:/apim/office365groups/380cef7ddacd49d2bdb5b747184c7d8a/v1.0/groups/202a2963-7e7d-4dc6-8aca-a58a2f3a9d53/events",
@ -149,16 +149,16 @@ namespace Microsoft.PowerFx.Connectors.Tests
"Response_O365Groups_HttpRequest.json")]
// In PA, a 3rd param is required for Body even though it is "required":false in swagger file
[InlineData(
@"Office365Groups.HttpRequestV2(""https://graph.microsoft.com/v1.0/groups/202a2963-7e7d-4dc6-8aca-a58a2f3a9d53/events"", ""GET"")",
[InlineData(
@"Office365Groups.HttpRequestV2(""https://graph.microsoft.com/v1.0/groups/202a2963-7e7d-4dc6-8aca-a58a2f3a9d53/events"", ""GET"")",
"RECORD",
"POST:/apim/office365groups/380cef7ddacd49d2bdb5b747184c7d8a/v2/httprequest",
"",
"Response_O365Groups_HttpRequestV2.json")]
"Response_O365Groups_HttpRequestV2.json")]
public async Task Office365Groups_Functions(string expr, string expectedResult, string xUrls, string xBodies, params string[] expectedFiles)
{
await RunConnectorTestAsync(false, expr, expectedResult, xUrls, xBodies, expectedFiles, true).ConfigureAwait(false);
}
}
[Theory]
[InlineData("First(Office365Groups", "Office365Groups|Office365Groups.AddMemberToGroup|Office365Groups.CalendarDeleteItemV2|Office365Groups.CreateCalendarEventV2|Office365Groups.HttpRequestV2|Office365Groups.ListGroupMembers|Office365Groups.ListGroups|Office365Groups.ListOwnedGroups|Office365Groups.ListOwnedGroupsV2|Office365Groups.ListOwnedGroupsV3|Office365Groups.RemoveMemberFromGroup|Office365Groups.UpdateCalendarEvent")]
@ -166,12 +166,12 @@ namespace Microsoft.PowerFx.Connectors.Tests
[InlineData("First(Office365Groups.Lis", "ListGroupMembers|ListGroups|ListOwnedGroups|ListOwnedGroupsV2|ListOwnedGroupsV3")]
[InlineData("First(Office365Groups.ListGroups(", "ListGroups({ $filter:String,$top:Decimal,$skiptoken:String })")]
[InlineData("First(Filter(Office365Groups.ListGroups().", "value:Table|'OData context':String|'OData NextLink':String")]
[InlineData("First(Filter(Office365Groups.ListGroups().value,", "classification:String|createdDateTime:DateTime|description:String|displayName:String|id:String|mail:String|mailEnabled:Boolean|mailNickname:String|onPremisesLastSyncDateTime:String|onPremisesSecurityIdentifier:String|onPremisesSyncEnabled:Boolean|renewedDateTime:DateTime|securityEnabled:Boolean|ThisRecord:Record|visibility:String")]
[InlineData("First(Filter(Office365Groups.ListGroups().value, ThisRecord.", "classification:String|createdDateTime:DateTime|description:String|displayName:String|id:String|mail:String|mailEnabled:Boolean|mailNickname:String|onPremisesLastSyncDateTime:String|onPremisesSecurityIdentifier:String|onPremisesSyncEnabled:Boolean|renewedDateTime:DateTime|securityEnabled:Boolean|visibility:String")]
[InlineData("First(Filter(Office365Groups.ListGroups().value, mail", "mail:String|mailEnabled:Boolean|mailNickname:String")]
[InlineData("First(Filter(Office365Groups.ListGroups().value,", "Classification:String|'Created Date-Time':DateTime|Description:String|Email:String|'Group Id':String|'Mail Enabled':Boolean|Name:String|Nickname:String|'On-Premises Last Sync Date-Time':String|'On-Premises Security Identifier':String|'On-Premises Sync Enabled':Boolean|'Renewed Date-Time':DateTime|'Security Enabled':Boolean|ThisRecord:Record|Visibility:String")]
[InlineData("First(Filter(Office365Groups.ListGroups().value, ThisRecord.", "Classification:String|'Created Date-Time':DateTime|Description:String|Email:String|'Group Id':String|'Mail Enabled':Boolean|Name:String|Nickname:String|'On-Premises Last Sync Date-Time':String|'On-Premises Security Identifier':String|'On-Premises Sync Enabled':Boolean|'Renewed Date-Time':DateTime|'Security Enabled':Boolean|Visibility:String")]
[InlineData("First(Filter(Office365Groups.ListGroups().value, mail", "Email:String|'Mail Enabled':Boolean")]
public async Task Office365Groups_ListGroups_Intellisense(string expr, string expectedSuggestions)
{
RunIntellisenseTest(expr, expectedSuggestions);
}
}
}
}

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

@ -1788,12 +1788,12 @@ POST https://tip1-shared-002.azure-apim.net/invoke
string ft = returnType.FormulaType.ToStringWithDisplayNames();
string expected =
"!['@odata.nextLink':s, value:*[Array:!['@odata.id'`'OData Id':s, _createdby_value`'Created By (Value)':s, '_createdby_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Created By (Type)':s, _createdbyexternalparty_value`'Created " +
"By (External Party) (Value)':s, '_createdbyexternalparty_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Created By (External Party) (Type)':s, _createdonbehalfby_value`'Created By (Delegate) (Value)':s, " +
"'_createdonbehalfby_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Created By (Delegate) (Type)':s, _defaultpricelevelid_value`'Price List (Value)':s, '_defaultpricelevelid_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Price " +
"List (Type)':s, _masterid_value`'Master ID (Value)':s, '_masterid_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Master ID (Type)':s, _modifiedby_value`'Modified By (Value)':s, '_modifiedby_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'" +
"Modified By (Type)':s, _modifiedbyexternalparty_value`'Modified By (External Party) (Value)':s, '_modifiedbyexternalparty_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Modified By (External Party) (Type)':s, " +
"_modifiedonbehalfby_value`'Modified By (Delegate) (Value)':s, '_modifiedonbehalfby_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Modified By (Delegate) (Type)':s, _msa_managingpartnerid_value`'Managing " +
"!['@odata.nextLink'`'Next link':s, value:*[Array:!['@odata.id'`'OData Id':s, _createdby_value`'Created By (Value)':s, '_createdby_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Created By (Type)':s, " +
"_createdbyexternalparty_value`'Created By (External Party) (Value)':s, '_createdbyexternalparty_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Created By (External Party) (Type)':s, _createdonbehalfby_value`'Created " +
"By (Delegate) (Value)':s, '_createdonbehalfby_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Created By (Delegate) (Type)':s, _defaultpricelevelid_value`'Price List (Value)':s, '_defaultpricelevelid_value@Microsoft.Dynamics.CRM.lookuplogic" +
"alname'`'Price List (Type)':s, _masterid_value`'Master ID (Value)':s, '_masterid_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Master ID (Type)':s, _modifiedby_value`'Modified By (Value)':s, '_modifiedby_value@Microsoft.Dynamics.CRM.looku" +
"plogicalname'`'Modified By (Type)':s, _modifiedbyexternalparty_value`'Modified By (External Party) (Value)':s, '_modifiedbyexternalparty_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Modified By (External " +
"Party) (Type)':s, _modifiedonbehalfby_value`'Modified By (Delegate) (Value)':s, '_modifiedonbehalfby_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Modified By (Delegate) (Type)':s, _msa_managingpartnerid_value`'Managing " +
"Partner (Value)':s, '_msa_managingpartnerid_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Managing Partner (Type)':s, _msdyn_accountkpiid_value`'KPI (Value)':s, '_msdyn_accountkpiid_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'KPI " +
"(Type)':s, _msdyn_salesaccelerationinsightid_value`'Sales Acceleration Insights ID (Value)':s, '_msdyn_salesaccelerationinsightid_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Sales Acceleration Insights " +
"ID (Type)':s, _originatingleadid_value`'Originating Lead (Value)':s, '_originatingleadid_value@Microsoft.Dynamics.CRM.lookuplogicalname'`'Originating Lead (Type)':s, _ownerid_value`'Owner (Value)':s, '_ownerid_value@Microsoft.Dynamics.CRM.lo" +