public async Task <APITemplateResource> CreateAPITemplateResourceAsync(APIConfig api, bool isSplit, bool isInitial)
        {
            // create api resource
            APITemplateResource apiTemplateResource = new APITemplateResource()
            {
                name       = $"[concat(parameters('ApimServiceName'), '/{api.name}')]",
                type       = ResourceTypeConstants.API,
                apiVersion = GlobalConstants.APIVersion,
                properties = new APITemplateProperties(),
                dependsOn  = new string[] { }
            };

            // add properties depending on whether the template is the initial, subsequent, or unified
            if (!isSplit || isInitial)
            {
                // add metadata properties for initial and unified templates
                // protocols can be pulled by converting the OpenApiSpec into the OpenApiDocument class
                OpenAPISpecReader openAPISpecReader = new OpenAPISpecReader();
                OpenApiDocument   doc = await openAPISpecReader.ConvertOpenAPISpecToDoc(api.openApiSpec);

                // supplied via optional arguments
                apiTemplateResource.properties.apiVersion             = api.apiVersion;
                apiTemplateResource.properties.subscriptionRequired   = api.subscriptionRequired;
                apiTemplateResource.properties.apiRevision            = api.revision;
                apiTemplateResource.properties.apiRevisionDescription = api.revisionDescription;
                apiTemplateResource.properties.apiVersionDescription  = api.apiVersionDescription;
                apiTemplateResource.properties.authenticationSettings = api.authenticationSettings;
                apiTemplateResource.properties.path        = api.suffix;
                apiTemplateResource.properties.isCurrent   = api.isCurrent;
                apiTemplateResource.properties.displayName = api.name;
                apiTemplateResource.properties.protocols   = this.CreateProtocols(doc);
                // set the version set id
                if (api.apiVersionSetId != null)
                {
                    // point to the supplied version set if the apiVersionSetId is provided
                    apiTemplateResource.properties.apiVersionSetId = $"[resourceId('Microsoft.ApiManagement/service/apiVersionSets', parameters('ApimServiceName'), '{api.apiVersionSetId}')]";
                }
                // set the authorization server id
                if (api.authenticationSettings != null && api.authenticationSettings.oAuth2 != null && api.authenticationSettings.oAuth2.authorizationServerId != null &&
                    apiTemplateResource.properties.authenticationSettings != null && apiTemplateResource.properties.authenticationSettings.oAuth2 != null && apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId != null)
                {
                    apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId = $"[resourceId('Microsoft.ApiManagement/service/authorizationServers', parameters('ApimServiceName'), '{api.authenticationSettings.oAuth2.authorizationServerId}')]";
                }
            }
            if (!isSplit || !isInitial)
            {
                // add swagger properties for subsequent and unified templates
                Uri  uriResult;
                bool isUrl = Uri.TryCreate(api.openApiSpec, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
                // used to escape sequences in local swagger json
                object deserializedFileContents = isUrl ? null : JsonConvert.DeserializeObject <object>(this.fileReader.RetrieveLocalFileContents(api.openApiSpec));
                // if openApiSpec is a url inline the url, if it is a local file inline the file contents
                apiTemplateResource.properties.format = isUrl ? "swagger-link-json" : "swagger-json";
                apiTemplateResource.properties.value  = isUrl ? api.openApiSpec : JsonConvert.SerializeObject(deserializedFileContents);
                // supplied via optional arguments
                apiTemplateResource.properties.path = api.suffix;
            }
            return(apiTemplateResource);
        }
        private async Task <ApiTemplateResource> CreateApiTemplateResourceAsync(ApiDeploymentDefinition api, bool isInitial)
        {
            ApiTemplateResource apiTemplateResource = new ApiTemplateResource()
            {
                Name       = $"[concat(parameters('ApimServiceName'), '/{api.Name}')]",
                Properties = new ApiProperties(),
                DependsOn  = new string[] { }
            };

            if (isInitial)
            {
                var openAPISpecReader = new OpenAPISpecReader(api.OpenApiSpec);

                apiTemplateResource.Properties.Format = await openAPISpecReader.GetOpenApiFormat();

                apiTemplateResource.Properties.Value = await openAPISpecReader.GetValue();;
                apiTemplateResource.Properties.Path  = api.Path;
            }
            else
            {
                var path = api.Path.Replace("//", "/");
                if (path.StartsWith("/"))
                {
                    path = path.Substring(1);
                }

                apiTemplateResource.Properties.ApiVersion                    = api.ApiVersion;
                apiTemplateResource.Properties.ServiceUrl                    = api.ServiceUrl;
                apiTemplateResource.Properties.Type                          = api.Type;
                apiTemplateResource.Properties.ApiType                       = api.ApiType;
                apiTemplateResource.Properties.Description                   = api.Description;
                apiTemplateResource.Properties.SubscriptionRequired          = api.SubscriptionRequired;
                apiTemplateResource.Properties.ApiRevision                   = api.ApiRevision;
                apiTemplateResource.Properties.ApiRevisionDescription        = api.ApiRevisionDescription;
                apiTemplateResource.Properties.ApiVersionDescription         = api.ApiVersionDescription;
                apiTemplateResource.Properties.AuthenticationSettings        = api.AuthenticationSettings;
                apiTemplateResource.Properties.Path                          = path;
                apiTemplateResource.Properties.IsCurrent                     = api.IsCurrent;
                apiTemplateResource.Properties.DisplayName                   = api.DisplayName;
                apiTemplateResource.Properties.SubscriptionKeyParameterNames = api.SubscriptionKeyParameterNames;
                apiTemplateResource.Properties.Protocols                     = api.Protocols.GetItems(new[] { "https" });

                if (api.ApiVersionSetId != null)
                {
                    apiTemplateResource.Properties.ApiVersionSetId = $"[resourceId('{ResourceType.ApiVersionSet}', parameters('ApimServiceName'), '{api.ApiVersionSetId}')]";
                }

                if (api.AuthenticationSettings != null && api.AuthenticationSettings.OAuth2 != null && api.AuthenticationSettings.OAuth2.AuthorizationServerId != null &&
                    apiTemplateResource.Properties.AuthenticationSettings != null && apiTemplateResource.Properties.AuthenticationSettings.OAuth2 != null && apiTemplateResource.Properties.AuthenticationSettings.OAuth2.AuthorizationServerId != null)
                {
                    apiTemplateResource.Properties.AuthenticationSettings.OAuth2.AuthorizationServerId = api.AuthenticationSettings.OAuth2.AuthorizationServerId;
                }
            }

            return(apiTemplateResource);
        }
        public async Task <APITemplateResource> CreateInitialAPITemplateResourceAsync(CreatorConfig creatorConfig)
        {
            // protocols can be pulled by converting the OpenApiSpec into the OpenApiDocument class
            OpenAPISpecReader openAPISpecReader = new OpenAPISpecReader();
            OpenApiDocument   doc = await openAPISpecReader.ConvertOpenAPISpecToDoc(creatorConfig.api.openApiSpec);

            // create api resource with properties
            APITemplateResource apiTemplateResource = new APITemplateResource()
            {
                name       = $"[concat(parameters('ApimServiceName'), '/{creatorConfig.api.name}')]",
                type       = "Microsoft.ApiManagement/service/apis",
                apiVersion = "2018-06-01-preview",
                properties = new APITemplateProperties()
                {
                    // supplied via optional arguments
                    apiVersion             = creatorConfig.api.apiVersion,
                    subscriptionRequired   = creatorConfig.api.subscriptionRequired,
                    apiRevision            = creatorConfig.api.revision,
                    apiRevisionDescription = creatorConfig.api.revisionDescription,
                    apiVersionDescription  = creatorConfig.api.apiVersionDescription,
                    authenticationSettings = creatorConfig.api.authenticationSettings,
                    path        = creatorConfig.api.suffix,
                    displayName = creatorConfig.api.name,
                    protocols   = this.CreateProtocols(doc)
                },
                // if the template is not linked the depends on for the apiVersionSet needs to be inlined here
                dependsOn = new string[] { }
            };
            string versionSetId = (creatorConfig.apiVersionSet != null && creatorConfig.apiVersionSet.id != null) ? creatorConfig.apiVersionSet.id : "versionset";

            // if the template is linked and a version set was created, the initial api depends on it
            if (creatorConfig.linked == false && creatorConfig.apiVersionSet != null)
            {
                apiTemplateResource.dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/api-version-sets', parameters('ApimServiceName'), '{versionSetId}')]" };
            }
            // set the version set id
            if (creatorConfig.apiVersionSet != null)
            {
                apiTemplateResource.properties.apiVersionSetId = $"[resourceId('Microsoft.ApiManagement/service/api-version-sets', parameters('ApimServiceName'), '{versionSetId}')]";
            }
            else if (creatorConfig.api.apiVersionSetId != null)
            {
                apiTemplateResource.properties.apiVersionSetId = $"{creatorConfig.api.apiVersionSetId}";
            }
            return(apiTemplateResource);
        }
        public async Task <APITemplateResource> CreateAPITemplateResourceAsync(APIConfig api, bool isSplit, bool isInitial)
        {
            // create api resource
            APITemplateResource apiTemplateResource = new APITemplateResource()
            {
                name       = $"[concat(parameters('ApimServiceName'), '/{api.name}')]",
                type       = ResourceTypeConstants.API,
                apiVersion = GlobalConstants.APIVersion,
                properties = new APITemplateProperties(),
                dependsOn  = new string[] { }
            };

            // add properties depending on whether the template is the initial, subsequent, or unified
            if (!isSplit || isInitial)
            {
                // add metadata properties for initial and unified templates
                apiTemplateResource.properties.apiVersion             = api.apiVersion;
                apiTemplateResource.properties.serviceUrl             = api.serviceUrl;
                apiTemplateResource.properties.type                   = api.type;
                apiTemplateResource.properties.apiType                = api.type;
                apiTemplateResource.properties.description            = api.description;
                apiTemplateResource.properties.subscriptionRequired   = api.subscriptionRequired;
                apiTemplateResource.properties.apiRevision            = api.apiRevision;
                apiTemplateResource.properties.apiRevisionDescription = api.apiRevisionDescription;
                apiTemplateResource.properties.apiVersionDescription  = api.apiVersionDescription;
                apiTemplateResource.properties.authenticationSettings = api.authenticationSettings;
                apiTemplateResource.properties.path                   = api.suffix;
                apiTemplateResource.properties.isCurrent              = api.isCurrent;
                apiTemplateResource.properties.displayName            = api.name;
                apiTemplateResource.properties.protocols              = this.CreateProtocols(api);
                // set the version set id
                if (api.apiVersionSetId != null)
                {
                    // point to the supplied version set if the apiVersionSetId is provided
                    apiTemplateResource.properties.apiVersionSetId = $"[resourceId('Microsoft.ApiManagement/service/apiVersionSets', parameters('ApimServiceName'), '{api.apiVersionSetId}')]";
                }
                // set the authorization server id
                if (api.authenticationSettings != null && api.authenticationSettings.oAuth2 != null && api.authenticationSettings.oAuth2.authorizationServerId != null &&
                    apiTemplateResource.properties.authenticationSettings != null && apiTemplateResource.properties.authenticationSettings.oAuth2 != null && apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId != null)
                {
                    apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId = api.authenticationSettings.oAuth2.authorizationServerId;
                }
            }
            if (!isSplit || !isInitial)
            {
                // add open api spec properties for subsequent and unified templates
                string format;
                string value;

                // determine if the open api spec is remote or local, yaml or json
                Uri    uriResult;
                string fileContents = await this.fileReader.RetrieveFileContentsAsync(api.openApiSpec);

                bool isJSON = this.fileReader.isJSON(fileContents);
                bool isUrl  = Uri.TryCreate(api.openApiSpec, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);

                if (isUrl == true)
                {
                    value = api.openApiSpec;
                    if (isJSON == true)
                    {
                        // open api spec is remote json file, use swagger-link-json for v2 and openapi-link for v3
                        OpenAPISpecReader openAPISpecReader = new OpenAPISpecReader();
                        bool isVersionThree = await openAPISpecReader.isJSONOpenAPISpecVersionThreeAsync(api.openApiSpec);

                        format = isVersionThree == false ? "swagger-link-json" : "openapi-link";
                    }
                    else
                    {
                        // open api spec is remote yaml file
                        format = "openapi-link";
                    }
                }
                else
                {
                    value = fileContents;
                    if (isJSON == true)
                    {
                        // open api spec is local json file, use swagger-json for v2 and openapi+json for v3
                        OpenAPISpecReader openAPISpecReader = new OpenAPISpecReader();
                        bool isVersionThree = await openAPISpecReader.isJSONOpenAPISpecVersionThreeAsync(api.openApiSpec);

                        format = isVersionThree == false ? "swagger-json" : "openapi+json";
                    }
                    else
                    {
                        // open api spec is local yaml file
                        format = "openapi";
                    }
                }
                apiTemplateResource.properties.format = format;
                apiTemplateResource.properties.value  = value;
                apiTemplateResource.properties.path   = api.suffix;
            }
            return(apiTemplateResource);
        }
        public async Task <APITemplateResource> CreateAPITemplateResourceAsync(APIConfig api, bool isSplit, bool isInitial)
        {
            // create api resource
            APITemplateResource apiTemplateResource = new APITemplateResource()
            {
                name       = MakeResourceName(api),
                type       = ResourceTypeConstants.API,
                apiVersion = GlobalConstants.APIVersion,
                properties = new APITemplateProperties(),
                dependsOn  = new string[] { }
            };

            // add properties depending on whether the template is the initial, subsequent, or unified
            if (!isSplit || !isInitial)
            {
                // add metadata properties for initial and unified templates
                apiTemplateResource.properties.apiVersion                    = api.apiVersion;
                apiTemplateResource.properties.serviceUrl                    = MakeServiceUrl(api);
                apiTemplateResource.properties.type                          = api.type;
                apiTemplateResource.properties.apiType                       = api.type;
                apiTemplateResource.properties.description                   = api.description;
                apiTemplateResource.properties.subscriptionRequired          = api.subscriptionRequired;
                apiTemplateResource.properties.apiRevision                   = api.apiRevision;
                apiTemplateResource.properties.apiRevisionDescription        = api.apiRevisionDescription;
                apiTemplateResource.properties.apiVersionDescription         = api.apiVersionDescription;
                apiTemplateResource.properties.authenticationSettings        = api.authenticationSettings;
                apiTemplateResource.properties.subscriptionKeyParameterNames = api.subscriptionKeyParameterNames;
                apiTemplateResource.properties.path                          = api.suffix;
                apiTemplateResource.properties.isCurrent                     = api.isCurrent;
                apiTemplateResource.properties.displayName                   = string.IsNullOrEmpty(api.displayName) ? api.name : api.displayName;
                apiTemplateResource.properties.protocols                     = this.CreateProtocols(api);
                // set the version set id
                if (api.apiVersionSetId != null)
                {
                    // point to the supplied version set if the apiVersionSetId is provided
                    apiTemplateResource.properties.apiVersionSetId = $"[resourceId('Microsoft.ApiManagement/service/apiVersionSets', parameters('{ParameterNames.ApimServiceName}'), '{api.apiVersionSetId}')]";
                }
                // set the authorization server id
                if (api.authenticationSettings != null && api.authenticationSettings.oAuth2 != null && api.authenticationSettings.oAuth2.authorizationServerId != null &&
                    apiTemplateResource.properties.authenticationSettings != null && apiTemplateResource.properties.authenticationSettings.oAuth2 != null && apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId != null)
                {
                    apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId = api.authenticationSettings.oAuth2.authorizationServerId;
                }
                // set the subscriptionKey Parameter Names
                if (api.subscriptionKeyParameterNames != null)
                {
                    if (api.subscriptionKeyParameterNames.header != null)
                    {
                        apiTemplateResource.properties.subscriptionKeyParameterNames.header = api.subscriptionKeyParameterNames.header;
                    }
                    if (api.subscriptionKeyParameterNames.query != null)
                    {
                        apiTemplateResource.properties.subscriptionKeyParameterNames.query = api.subscriptionKeyParameterNames.query;
                    }
                }
            }
            if (!isSplit || isInitial)
            {
                // add open api spec properties for subsequent and unified templates
                string format;
                string value;

                // determine if the open api spec is remote or local, yaml or json
                bool isJSON = false;
                bool isUrl  = IsUri(api, out var _);

                string fileContents = null;
                if (!isUrl || api.openApiSpecFormat == OpenApiSpecFormat.Unspecified)
                {
                    fileContents = await this.fileReader.RetrieveFileContentsAsync(api.openApiSpec);
                }

                value = isUrl
                    ? api.openApiSpec
                    : fileContents
                ;

                bool isVersionThree = false;
                if (api.openApiSpecFormat == OpenApiSpecFormat.Unspecified)
                {
                    isJSON = this.fileReader.isJSON(fileContents);

                    if (isJSON == true)
                    {
                        var openAPISpecReader = new OpenAPISpecReader();
                        isVersionThree = await openAPISpecReader.isJSONOpenAPISpecVersionThreeAsync(api.openApiSpec);
                    }
                    format = GetOpenApiSpecFormat(isUrl, isJSON, isVersionThree);
                }

                else
                {
                    isJSON = IsOpenApiSpecJson(api.openApiSpecFormat);
                    format = GetOpenApiSpecFormat(isUrl, api.openApiSpecFormat);
                }

                // if the title needs to be modified
                // we need to embed the OpenAPI definition

                if (!string.IsNullOrEmpty(api.displayName))
                {
                    format = GetOpenApiSpecFormat(false, isJSON, isVersionThree);

                    // download definition

                    if (isUrl)
                    {
                        using (var client = new WebClient())
                            value = client.DownloadString(value);
                    }

                    // update title

                    value = new OpenApi(value, format)
                            .SetTitle(api.displayName)
                            .GetDefinition()
                    ;
                }

                // set the version set id
                if (api.apiVersionSetId != null)
                {
                    // point to the supplied version set if the apiVersionSetId is provided
                    apiTemplateResource.properties.apiVersionSetId = $"[resourceId('Microsoft.ApiManagement/service/apiVersionSets', parameters('{ParameterNames.ApimServiceName}'), '{api.apiVersionSetId}')]";
                }
                apiTemplateResource.properties.format = format;
                apiTemplateResource.properties.value  = value;
                apiTemplateResource.properties.path   = api.suffix;
                if (!String.IsNullOrEmpty(api.serviceUrl))
                {
                    apiTemplateResource.properties.serviceUrl = MakeServiceUrl(api);
                }
            }
            return(apiTemplateResource);
        }
        public async Task <APITemplateResource> CreateAPITemplateResourceAsync(APIConfig api, bool isSplit, bool isInitial, bool mergeTemplates = false)
        {
            // create api resource
            APITemplateResource apiTemplateResource = new APITemplateResource()
            {
                name       = MakeResourceName(api),
                type       = ResourceTypeConstants.API,
                apiVersion = GlobalConstants.APIVersion,
                properties = new APITemplateProperties(),
                dependsOn  = new string[] { }
            };

            // add properties depending on whether the template is the initial, subsequent, or unified
            if (!isSplit || !isInitial)
            {
                // add metadata properties for initial and unified templates
                apiTemplateResource.properties.apiVersion                    = api.apiVersion;
                apiTemplateResource.properties.serviceUrl                    = $"[parameters('{ParameterNames.ServiceUrl}')]";
                apiTemplateResource.properties.type                          = api.type;
                apiTemplateResource.properties.apiType                       = api.type;
                apiTemplateResource.properties.description                   = api.description;
                apiTemplateResource.properties.subscriptionRequired          = api.subscriptionRequired;
                apiTemplateResource.properties.apiRevision                   = api.apiRevision;
                apiTemplateResource.properties.apiRevisionDescription        = api.apiRevisionDescription;
                apiTemplateResource.properties.apiVersionDescription         = api.apiVersionDescription;
                apiTemplateResource.properties.authenticationSettings        = api.authenticationSettings;
                apiTemplateResource.properties.subscriptionKeyParameterNames = api.subscriptionKeyParameterNames;
                apiTemplateResource.properties.path                          = api.suffix;
                apiTemplateResource.properties.isCurrent                     = api.isCurrent;
                apiTemplateResource.properties.displayName                   = string.IsNullOrEmpty(api.displayName) ? api.name : api.displayName;
                apiTemplateResource.properties.protocols                     = this.CreateProtocols(api);
                // set the version set id
                if (api.apiVersionSetId != null)
                {
                    // point to the supplied version set if the apiVersionSetId is provided
                    apiTemplateResource.properties.apiVersionSetId = $"[resourceId('Microsoft.ApiManagement/service/apiVersionSets', parameters('{ParameterNames.ApimServiceName}'), '{api.apiVersionSetId}')]";
                }
                // set the authorization server id
                if (api.authenticationSettings != null && api.authenticationSettings.oAuth2 != null && api.authenticationSettings.oAuth2.authorizationServerId != null &&
                    apiTemplateResource.properties.authenticationSettings != null && apiTemplateResource.properties.authenticationSettings.oAuth2 != null && apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId != null)
                {
                    apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId = api.authenticationSettings.oAuth2.authorizationServerId;
                }
                // set the subscriptionKey Parameter Names
                if (api.subscriptionKeyParameterNames != null)
                {
                    if (api.subscriptionKeyParameterNames.header != null)
                    {
                        apiTemplateResource.properties.subscriptionKeyParameterNames.header = api.subscriptionKeyParameterNames.header;
                    }
                    if (api.subscriptionKeyParameterNames.query != null)
                    {
                        apiTemplateResource.properties.subscriptionKeyParameterNames.query = api.subscriptionKeyParameterNames.query;
                    }
                }
            }
            if (!isSplit || isInitial)
            {
                // add open api spec properties for subsequent and unified templates
                string format;
                string value;

                // determine if the open api spec is remote or local, yaml or json
                Uri    uriResult;
                string fileContents = await this.fileReader.RetrieveFileContentsAsync(api.openApiSpec);

                bool isJSON = this.fileReader.isJSON(fileContents);
                bool isUrl  = Uri.TryCreate(api.openApiSpec, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);

                value = isUrl
                    ? api.openApiSpec
                    : fileContents
                ;

                bool isVersionThree = false;
                if (isJSON == true)
                {
                    // open api spec is remote json file, use swagger-link-json for v2 and openapi-link for v3
                    OpenAPISpecReader openAPISpecReader = new OpenAPISpecReader();
                    isVersionThree = await openAPISpecReader.isJSONOpenAPISpecVersionThreeAsync(api.openApiSpec);
                }

                format = isUrl
                    ? (isJSON ? (isVersionThree ? "openapi-link" : "swagger-link-json") : "openapi-link")
                    : (isJSON ? (isVersionThree ? "openapi+json" : "swagger-json") : "openapi")
                ;

                // if the title needs to be modified
                // we need to embed the OpenAPI definition

                if (!string.IsNullOrEmpty(api.displayName))
                {
                    format = (isJSON ? (isVersionThree ? "openapi+json" : "swagger-json") : "openapi");

                    // download definition

                    if (isUrl)
                    {
                        using (var client = new WebClient())
                            value = client.DownloadString(value);
                    }

                    // update title

                    value = new OpenApi(value, format)
                            .SetTitle(api.displayName)
                            .GetDefinition()
                    ;
                }
                // set the version set id
                if (api.apiVersionSetId != null)
                {
                    // point to the supplied version set if the apiVersionSetId is provided
                    apiTemplateResource.properties.apiVersionSetId = $"[resourceId('Microsoft.ApiManagement/service/apiVersionSets', parameters('{ParameterNames.ApimServiceName}'), '{api.apiVersionSetId}')]";
                }
                apiTemplateResource.properties.apiVersion = api.apiVersion;
                apiTemplateResource.properties.format     = format;
                apiTemplateResource.properties.value      = value;
                apiTemplateResource.properties.path       = api.suffix;
                apiTemplateResource.properties.serviceUrl = $"[parameters('{ParameterNames.ServiceUrl}')]";
                if (mergeTemplates)
                {
                    apiTemplateResource.dependsOn = apiTemplateResource.dependsOn.Append($"[resourceId('Microsoft.ApiManagement/service/apiVersionSets', parameters('{ParameterNames.ApimServiceName}'), '{api.apiVersionSetId}')]").ToArray();
                }
            }
            return(apiTemplateResource);
        }