Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit a183548

Browse files
fortunkamMatthew Fortunka
andauthored
Added Test for list size to fix #466 (#467)
Co-authored-by: Matthew Fortunka <mafortun@microsoft.com>
1 parent 18cea0d commit a183548

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/APIM_ARMTemplate/apimtemplate/Extractor/EntityExtractors/TagAPIExtractor.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,20 @@ public async Task<Template> GenerateAPITagsARMTemplateAsync(string singleApiName
153153
{
154154
string apiName = ((JValue)oApi["name"]).Value.ToString();
155155
templateResources.AddRange(await GenerateSingleAPITagResourceAsync(apiName, exc, dependsOn));
156-
157-
// Extract the tag name from the last resource
158-
string[] lastTagName = templateResources.Last().name.Replace("')]", "").Split('/');
159-
if (lastTagName.Length > 3)
156+
if (templateResources.Count > 0)
160157
{
161-
// Operations tag
162-
dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/apis/operations/tags', parameters('{ParameterNames.ApimServiceName}'), '{apiName}', '{lastTagName[2]}', '{lastTagName[3]}')]" };
163-
}
164-
else
165-
{
166-
// API tag
167-
dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/apis/tags', parameters('{ParameterNames.ApimServiceName}'), '{apiName}', '{lastTagName[2]}')]" };
158+
// Extract the tag name from the last resource
159+
string[] lastTagName = templateResources.Last().name.Replace("')]", "").Split('/');
160+
if (lastTagName.Length > 3)
161+
{
162+
// Operations tag
163+
dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/apis/operations/tags', parameters('{ParameterNames.ApimServiceName}'), '{apiName}', '{lastTagName[2]}', '{lastTagName[3]}')]" };
164+
}
165+
else
166+
{
167+
// API tag
168+
dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/apis/tags', parameters('{ParameterNames.ApimServiceName}'), '{apiName}', '{lastTagName[2]}')]" };
169+
}
168170
}
169171
}
170172
}

0 commit comments

Comments
 (0)