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

fix: Resolved operation schema does not exists error #872

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ public async Task<List<ApiOperationTemplateResource>> 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)
Expand Down Expand Up @@ -86,5 +95,17 @@ static void AddSchemaDependencyToOperationIfNecessary(string apiName, List<strin
}
}
}
static void AddSchemaDependencyToOperationIfNecessary(string apiName, List<string> 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);
}
}
}
}
}