예제 #1
0
        private protected override void ExecuteRuleLogic()
        {
            foreach (KeyValuePair <string, OpenApiPathItem> path in Contract.Paths)
            {
                if (Supressions.IsSupressed(ruleName, path.Key))
                {
                    continue;
                }

                string[] pathSplited = path.Key.Split('/');

                foreach (string pathSegment in pathSplited)
                {
                    if (!string.IsNullOrEmpty(pathSegment) &&
                        !pathSegment.Contains("{") &&
                        !pathSegment.GetCaseType(caseTypeTolerateNumber).Contains(caseType))
                    {
                        listResult.Add(
                            new ResultItem(this)
                        {
                            Description = Description
                                          .Replace("{0}", caseType.GetEnumDescription())
                                          .Replace("{1}", example),
                            Value = ResultItem.FormatValue(path: path.Key, pathSegment: pathSegment)
                        });
                    }
                }
            }
        }
예제 #2
0
        private protected override void ExecuteRuleLogic()
        {
            foreach (OpenApiDocumentExtensions.Parameter parameter in Contract.GetAllParameters())
            {
                if (Supressions.IsSupressed(ruleName, parameter.Path, parameter.Operation, parameter.Name))
                {
                    continue;
                }

                if (parameter.OpenApiParameter.In != ParameterLocation.Path)
                {
                    continue;
                }

                string cleanedParameter = parameter.Name;

                if (!string.IsNullOrEmpty(prefixToRemove))
                {
                    cleanedParameter = cleanedParameter
                                       .Remove(0, prefixToRemove.Length);
                }

                if (!string.IsNullOrEmpty(sufixToRemove))
                {
                    cleanedParameter = cleanedParameter
                                       .Remove(parameter.Name.LastIndexOf(sufixToRemove, StringComparison.Ordinal),
                                               sufixToRemove.Length);
                }

                cleanedParameter = cleanedParameter.ToLower();

                if (
                    !Regex.IsMatch(parameter.Name, regex) ||
                    cleanedParameter.CalculateSimilarityWith(parameter.ParentPathSegment) <
                    matchEntityNamePercentage)
                {
                    listResult.Add(
                        new ResultItem(this)
                    {
                        Description = Description
                                      .Replace("{0}", humanReadeableFormat)
                                      .Replace("{1}", caseType.GetEnumDescription())
                                      .Replace("{2}", example),
                        Value =
                            $"Path='{parameter.Path}',Operation='{parameter.Operation}',Parameter='{parameter.Name}'"
                    });
                }
            }
        }
예제 #3
0
        private protected override void ExecuteRuleLogic()
        {
            foreach (OpenApiDocumentExtensions.Property property in Contract.GetAllBodyProperties(RuleSettings, Cache))
            {
                if (Supressions.IsSupressed(ruleName, property.Path, property.Operation, string.Empty,
                                            property.ResponseCode, property.FullName))
                {
                    continue;
                }

                if (property.Name.GetCaseType(caseTypeTolerateNumber).First() != caseType)
                {
                    listResult.Add(
                        new ResultItem(this)
                    {
                        Description = Description
                                      .Replace("{0}", caseType.GetEnumDescription())
                                      .Replace("{1}", example),
                        Value = property.ResultLocation()
                    });
                }
            }
        }