@@ -20,12 +20,15 @@ public Template CreateProductAPITemplate(CreatorConfig creatorConfig)
20
20
string [ ] dependsOn = new string [ ] { } ;
21
21
foreach ( APIConfig api in creatorConfig . apis )
22
22
{
23
- List < ProductAPITemplateResource > apiResources = CreateProductAPITemplateResources ( api , dependsOn ) ;
24
- resources . AddRange ( apiResources ) ;
23
+ if ( api . products != null )
24
+ {
25
+ List < ProductAPITemplateResource > apiResources = CreateProductAPITemplateResources ( api , dependsOn ) ;
26
+ resources . AddRange ( apiResources ) ;
25
27
26
- // Add previous product/API resource as a dependency for next product/API resource(s)
27
- string productID = apiResources [ apiResources . Count - 1 ] . name . Split ( '/' , 3 ) [ 1 ] ;
28
- dependsOn = new string [ ] { $ "[resourceId('Microsoft.ApiManagement/service/products/apis', parameters('{ ParameterNames . ApimServiceName } '), '{ productID } ', '{ api . name } ')]" } ;
28
+ // Add previous product/API resource as a dependency for next product/API resource(s)
29
+ string productID = apiResources [ apiResources . Count - 1 ] . name . Split ( '/' , 3 ) [ 1 ] ;
30
+ dependsOn = new string [ ] { $ "[resourceId('Microsoft.ApiManagement/service/products/apis', parameters('{ ParameterNames . ApimServiceName } '), '{ productID } ', '{ api . name } ')]" } ;
31
+ }
29
32
}
30
33
31
34
productTemplate . resources = resources . ToArray ( ) ;
@@ -48,7 +51,7 @@ public List<ProductAPITemplateResource> CreateProductAPITemplateResources(APICon
48
51
// create a products/apis association resource for each product provided in the config file
49
52
List < ProductAPITemplateResource > productAPITemplates = new List < ProductAPITemplateResource > ( ) ;
50
53
// products is comma separated list of productIds
51
- string [ ] productIDs = api . products . Split ( ", " ) ;
54
+ string [ ] productIDs = ( api . products ?? "" ) . Split ( ", " , System . StringSplitOptions . RemoveEmptyEntries ) ;
52
55
string [ ] allDependsOn = dependsOn ;
53
56
foreach ( string productID in productIDs )
54
57
{
0 commit comments