Skip to content

Commit

Permalink
RequestError Error() does not include reason if it is the same as err (
Browse files Browse the repository at this point in the history
…#517)

Co-authored-by: Kanda <kanda@synctera.com>
  • Loading branch information
kandaaaaa and Kanda authored Mar 30, 2022
1 parent a5284e9 commit ca21ef5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion openapi3filter/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ interface{ Unwrap() error } = RequestError{}
func (err *RequestError) Error() string {
reason := err.Reason
if e := err.Err; e != nil {
if len(reason) == 0 {
if len(reason) == 0 || reason == e.Error() {
reason = e.Error()
} else {
reason += ": " + e.Error()
Expand Down
6 changes: 3 additions & 3 deletions openapi3filter/validation_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func getValidationTests(t *testing.T) []*validationTest {
},
wantErrParam: "status",
wantErrParamIn: "query",
wantErrBody: `parameter "status" in query has an error: value is required but missing: value is required but missing`,
wantErrBody: `parameter "status" in query has an error: value is required but missing`,
wantErrReason: "value is required but missing",
wantErrResponse: &ValidationError{Status: http.StatusBadRequest,
Title: `parameter "status" in query is required`},
Expand Down Expand Up @@ -214,7 +214,7 @@ func getValidationTests(t *testing.T) []*validationTest {
},
wantErrParam: "tags",
wantErrParamIn: "query",
wantErrBody: `parameter "tags" in query has an error: empty value is not allowed: empty value is not allowed`,
wantErrBody: `parameter "tags" in query has an error: empty value is not allowed`,
wantErrReason: "empty value is not allowed",
wantErrResponse: &ValidationError{Status: http.StatusBadRequest,
Title: `parameter "tags" in query is not allowed to be empty`},
Expand Down Expand Up @@ -444,7 +444,7 @@ func getValidationTests(t *testing.T) []*validationTest {
},
wantErrParam: "petId",
wantErrParamIn: "path",
wantErrBody: `parameter "petId" in path has an error: value is required but missing: value is required but missing`,
wantErrBody: `parameter "petId" in path has an error: value is required but missing`,
wantErrReason: "value is required but missing",
wantErrResponse: &ValidationError{Status: http.StatusBadRequest,
Title: `parameter "petId" in path is required`},
Expand Down

0 comments on commit ca21ef5

Please sign in to comment.