private static bool ParamsAreSame()

in openapi-diff/src/modeler/AutoRest.Swagger/Model/Operation.cs [378:418]


        private static bool ParamsAreSame(SwaggerParameter currParam, SwaggerParameter priorParam)
            => currParam != null && priorParam != null && currParam.Name == priorParam.Name &&
               currParam.In == priorParam.In;

        /// <summary>
        /// We assume that parameter location is "method" if, and only if, its order matters.
        /// </summary>
        private bool ParamLocationIsMethod((SwaggerParameter param, bool isGlobal) paramInfo)
            => ParamOrderMatters(paramInfo);

        /// <summary>
        /// Determines if given parameter's order matters. See the comments within this method for details,
        /// as well as comment on DetectChangedParameterOrder method.
        /// </summary>
        private bool ParamOrderMatters((SwaggerParameter param, bool isGlobal) paramInfo)
        {
            if (!paramInfo.isGlobal)
            {
                // If the parameter is not a global parameter then we assume its order matters.
                // We assume this because we assume that the parameters are generated into C# code
                // via AutoRest implementation. According to this implementation example in [1],
                // these parameters are by default method parameters, hence their order matters.
                // We also assume, as explained in [2], that it is not possible to override parameter
                // location to one whose order doesn't matter: the extension "x-ms-parameter-location"
                // will be ignored even if defined.
                // [1] https://github.com/Azure /autorest/blob/765bc784b0cad173d47f931a04724936a6948b4c/docs/generate/how-autorest-generates-code-from-openapi.md#specifying-required-parameters-and-properties
                // [2] https://github.com/Azure/autorest/blob/765bc784b0cad173d47f931a04724936a6948b4c/docs/extensions/readme.md#x-ms-parameter-location
                return true;
            }

            paramInfo.param.Extensions.TryGetValue("x-ms-parameter-location", out object paramLocation);

            // Per [2], if the global parameter definition does not declare "x-ms-parameter-location"
            // then we assume it defaults to "client" and so its order does not matter.
            // If the global parameter definition declares "x-ms-parameter-location" 
            // to any value different from "method", then we assume its order does not matter.
            // Otherwise, parameter either is not a global parameter, or its "x-ms-parameter-location" key
            // is set to "method", hence its order matters.
            // [2] https://github.com/Azure/autorest/blob/765bc784b0cad173d47f931a04724936a6948b4c/docs/extensions/readme.md#x-ms-parameter-location
            return paramLocation != null && paramLocation.Equals("method");
        }