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

Commit 84f57b0

Browse files
committed
add api version set id to creator config api property for existing version set linking
1 parent b35e299 commit 84f57b0

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
version: 0.0.1 # Required
2-
apimServiceName: testapimlucas # Required, must match name of an apim service deployed in the specified resource group
2+
apimServiceName: LucasUnlinked2 # Required, must match name of an apim service deployed in the specified resource group
33
apiVersionSet: # Optional
44
displayName: myAPIVersionSet
55
description: a description
66
versioningScheme: Query
77
versionQueryName: versionQuery
88
versionHeaderName: versionHeader
99
api:
10-
name: myAPI # Required
10+
name: myAPI2 # Required
1111
openApiSpec: C:\Users\lucashh\Desktop\Projects\APIM-ARM\azure-api-management-devops-example\src\APIM_ARMTemplate\apimtemplate\Creator\ExampleFiles\OpenApiSpecs\swaggerPetstore.json # Required, can be url or local file
1212
policy: C:\Users\lucashh\Desktop\Projects\APIM-ARM\azure-api-management-devops-example\src\APIM_ARMTemplate\apimtemplate\Creator\ExampleFiles\XMLPolicies\apiPolicyHeaders.xml # Optional, can be url or local file
1313
suffix: conf # Required
1414
apiVersion: v1 # Optional
1515
apiVersionDescription: My first version # Optional
16+
#apiVersionSetId: myID # Optional, must match the resource id on an existing version set
1617
revision: 1 # Optional
1718
revisionDescription: My first revision # Optional
1819
operations: # Optional
1920
addPet: # Must match the operationId property of a path's operations
2021
policy: C:\Users\lucashh\Desktop\Projects\APIM-ARM\azure-api-management-devops-example\src\APIM_ARMTemplate\apimtemplate\Creator\ExampleFiles\XMLPolicies\operationRateLimit.xml # Optional, can be url or local file
2122
deletePet: # Must match the operationId property of a path's operations
2223
policy: C:\Users\lucashh\Desktop\Projects\APIM-ARM\azure-api-management-devops-example\src\APIM_ARMTemplate\apimtemplate\Creator\ExampleFiles\XMLPolicies\operationRateLimit.xml # Optional, can be url or local file
23-
authenticationSettings: # Optional
24-
subscriptionKeyRequired: false
25-
oAuth2:
26-
authorizationServerId: serverId
27-
scope: scope
2824
products: starter, platinum # Optional, adds api to the specified products
2925
outputLocation: C:\Users\lucashh\Desktop\Projects\APIM-ARM\GeneratedTemplates # Required, folder the creator will write the templates to
30-
linked: true # Optional
26+
linked: false # Optional
3127
linkedTemplatesBaseUrl : https://lucasyamlblob.blob.core.windows.net/yaml # Required if 'linked' property is set to true

src/APIM_ARMTemplate/apimtemplate/Creator/Models/CreatorConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class APIConfig
2828
public string suffix { get; set; }
2929
public string apiVersion { get; set; }
3030
public string apiVersionDescription { get; set; }
31+
public string apiVersionSetId { get; set; }
3132
public string revision { get; set; }
3233
public string revisionDescription { get; set; }
3334
public Dictionary<string, OperationsConfig> operations { get; set; }

src/APIM_ARMTemplate/apimtemplate/Creator/TemplateCreators/APITemplateCreator.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,21 @@ public async Task<APITemplateResource> CreateInitialAPITemplateResource(CreatorC
7676
protocols = this.CreateProtocols(doc)
7777
},
7878
// if the template is not linked the depends on for the apiVersionSet needs to be inlined here
79-
dependsOn = creatorConfig.linked == true ? new string[] { } : new string[] { $"[resourceId('Microsoft.ApiManagement/service/api-version-sets', parameters('ApimServiceName'), 'versionset')]" }
79+
dependsOn = new string[] { }
8080
};
81+
if (creatorConfig.linked == false && creatorConfig.apiVersionSet != null)
82+
{
83+
apiTemplateResource.dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/api-version-sets', parameters('ApimServiceName'), 'versionset')]" };
84+
}
8185
if (creatorConfig.apiVersionSet != null)
8286
{
8387
apiTemplateResource.properties.apiVersionSetId = "[resourceId('Microsoft.ApiManagement/service/api-version-sets', parameters('ApimServiceName'), 'versionset')]";
8488
}
89+
else if (creatorConfig.api.apiVersionSetId != null)
90+
{
91+
apiTemplateResource.properties.apiVersionSetId = $"{creatorConfig.api.apiVersionSetId}";
92+
93+
}
8594
return apiTemplateResource;
8695
}
8796

0 commit comments

Comments
 (0)