diff --git a/CHANGELOG.md b/CHANGELOG.md index c8b59cf..6ce20be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ENHANCEMENTS: BUG FIXES: - Fix a bug that undocumented swagger properties caused inaccurate coverage report +- Remove duplicated items in the error report. ## v0.14.0 FEATURES: diff --git a/report/api_test_report.go b/report/api_test_report.go index bc178ff..0491fc4 100644 --- a/report/api_test_report.go +++ b/report/api_test_report.go @@ -77,6 +77,19 @@ func OavValidateTraffic(traceDir string, swaggerPath string, outputDir string) ( return nil, fmt.Errorf("oav report is empty") } + // remove duplicated error items + errorMap := make(map[string]ErrorItem) + for _, errItem := range payload.Errors { + errorMap[fmt.Sprintf("%s-%s-%s-%s", errItem.ErrorCode, errItem.ErrorMessage, errItem.OperationId, errItem.SchemaPathWithPosition)] = errItem + } + + errors := make([]ErrorItem, 0) + for _, v := range errorMap { + errors = append(errors, v) + } + + payload.Errors = errors + return payload, nil }