diff --git a/src/ArmTemplates/Extractor/EntityExtractors/ApiOperationExtractor.cs b/src/ArmTemplates/Extractor/EntityExtractors/ApiOperationExtractor.cs index 8994c991..c5331795 100644 --- a/src/ArmTemplates/Extractor/EntityExtractors/ApiOperationExtractor.cs +++ b/src/ArmTemplates/Extractor/EntityExtractors/ApiOperationExtractor.cs @@ -54,6 +54,15 @@ public async Task> GenerateApiOperationsResou } } + if (apiOperation.Properties?.Request?.QueryParameters?.IsNullOrEmpty() == false) + { + foreach (var requestQueryParams in apiOperation.Properties.Request.QueryParameters) + { + if (requestQueryParams.SchemaId?.IsNullOrEmpty() == false) + { AddSchemaDependencyToOperationIfNecessary(apiName, operationDependsOn, requestQueryParams); } + } + } + if (apiOperation.Properties?.Responses?.IsNullOrEmpty() == false) { foreach (var operationResponse in apiOperation.Properties?.Responses) @@ -86,5 +95,17 @@ static void AddSchemaDependencyToOperationIfNecessary(string apiName, List operationDependsOn, ApiOperationQueryParameter queryParameter) + { + if (queryParameter.SchemaId is not null) + { + string dependsOn = $"[resourceId('Microsoft.ApiManagement/service/apis/schemas', parameters('{ParameterNames.ApimServiceName}'), '{apiName}', '{queryParameter.SchemaId}')]"; + // add value to list if schema has not already been added + if (!operationDependsOn.Exists(o => o == dependsOn)) + { + operationDependsOn.Add(dependsOn); + } + } + } } }