private static SwaggerParameter FindReferencedParameter()

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


        private static SwaggerParameter FindReferencedParameter(
            string reference,
            IDictionary<string, SwaggerParameter> parameters)
        {
            if (reference != null && reference.StartsWith("#", StringComparison.Ordinal))
            {
                string[] parts = reference.Split('/');
                if (parts.Length == 3 && parts[1].Equals("parameters"))
                {
                    if (parameters.TryGetValue(parts[2], out var param))
                    {
                        return param;
                    }
                    else
                    {
                        // Given the parameter reference of form
                        // #/parameters/<paramName>
                        // the parameter named <paramName> could not be found in the "parameters"
                        // input to this method.
                        // Silently ignoring that param reference by doing nothing here.
                    }
                }
                else
                {
                    // The parameter reference does not conform to the format of: 
                    // #/parameters/<paramName>
                    // because it has different number of elements or its second element is not "parameters".
                    // Silently ignoring that param reference by doing nothing here.
                }
            }
            else
            {
                // The reference is null or does not start with "#".
                // Silently ignoring it by doing nothing here.
            }

            return null;
        }