in openapi-diff/src/modeler/AutoRest.Swagger/Model/Operation.cs [251:294]
private static (SwaggerParameter param, bool isGlobal) ResolveParam(SwaggerParameter param, ServiceDefinition serviceDef)
=> string.IsNullOrWhiteSpace(param.Reference)
? (param, false)
: (FindReferencedParameter(param.Reference, serviceDef.Parameters), true);
/// <summary>
/// Report breaking change if parameter location has changed.
/// See "1050 - ParameterLocationHasChanged" in docs/rules/1050.md for details.
///
/// We report ComparisonMessages.ParameterLocationHasChanged breaking change only if
/// given parameter existed in the previous version, still exists in the new version, and its location has changed.
/// </summary>
private void DetectChangedParameterLocation(
ComparisonContext<ServiceDefinition> context,
List<(SwaggerParameter param, bool isGlobal)> currParamsInfo,
List<(SwaggerParameter param, bool isGlobal)> priorParamsInfo)
{
priorParamsInfo.ForEach(
priorParamInfo
=>
{
(SwaggerParameter param, bool isGlobal) matchingCurrParamInfo = currParamsInfo.FirstOrDefault(
currParamInfo => ParamsAreSame(currParamInfo.param, priorParamInfo.param));
if (matchingCurrParamInfo != default)
{
var priorLocationIsMethod = ParamLocationIsMethod(priorParamInfo);
var currLocationIsMethod = ParamLocationIsMethod(matchingCurrParamInfo);
if (priorLocationIsMethod ^ currLocationIsMethod)
{
context.LogBreakingChange(
ComparisonMessages.ParameterLocationHasChanged,
priorParamInfo.param.Name,
priorParamInfo.param.In,
priorLocationIsMethod,
currLocationIsMethod);
}
}
else
{
// The parameter existed in the previous version but does not exist in the new version
// hence its location could not have changed.
}
});
}