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

Commit f587da9

Browse files
committed
split api if auth server is referenced, enable api-auth server linking
1 parent 6036a90 commit f587da9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/APIM_ARMTemplate/apimtemplate/Common/TemplateModels/APITemplateResource.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
using System;
3+
24
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common
35
{
46
public class APITemplateResource: TemplateResource
@@ -15,11 +17,11 @@ public class APITemplateProperties
1517
public string type { get; set; }
1618
public string apiRevision { get; set; }
1719
public string apiVersion { get; set; }
18-
public bool isCurrent { get; set; }
20+
public Nullable<bool> isCurrent { get; set; }
1921
public string apiRevisionDescription { get; set; }
2022
public string apiVersionDescription { get; set; }
2123
public string apiVersionSetId { get; set; }
22-
public bool subscriptionRequired { get; set; }
24+
public Nullable<bool> subscriptionRequired { get; set; }
2325
public string displayName { get; set; }
2426
public string serviceUrl { get; set; }
2527
public string path { get; set; }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public async Task<APITemplateResource> CreateAPITemplateResourceAsync(APIConfig
127127
if (api.authenticationSettings != null && api.authenticationSettings.oAuth2 != null && api.authenticationSettings.oAuth2.authorizationServerId != null
128128
&& apiTemplateResource.properties.authenticationSettings != null && apiTemplateResource.properties.authenticationSettings.oAuth2 != null && apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId != null)
129129
{
130-
apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId = $"[resourceId('Microsoft.ApiManagement/service/authorizationServers', parameters('ApimServiceName'), '{api.authenticationSettings.oAuth2.authorizationServerId}')]";
130+
apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId = api.authenticationSettings.oAuth2.authorizationServerId;
131131
}
132132
}
133133
if (!isSplit || !isInitial)
@@ -160,7 +160,7 @@ public string[] CreateProtocols(OpenApiDocument doc)
160160
public bool isSplitAPI(APIConfig apiConfig)
161161
{
162162
// the api needs to be split into multiple templates if the user has supplied a version or version set - deploying swagger related properties at the same time as api version related properties fails, so they must be written and deployed separately
163-
return apiConfig.apiVersion != null || apiConfig.apiVersionSetId != null;
163+
return apiConfig.apiVersion != null || apiConfig.apiVersionSetId != null || (apiConfig.authenticationSettings != null && apiConfig.authenticationSettings.oAuth2 != null && apiConfig.authenticationSettings.oAuth2.authorizationServerId != null);
164164
}
165165
}
166166
}

0 commit comments

Comments
 (0)