Skip to content

Commit

Permalink
Merge pull request #106 from Azure/branch-240902-remove-duplicated-er…
Browse files Browse the repository at this point in the history
…ror-items

remove duplicated error items
  • Loading branch information
ms-henglu authored Sep 2, 2024
2 parents f08f5dc + 6767e07 commit d6a1a8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions report/api_test_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit d6a1a8a

Please sign in to comment.