Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openapi3/issue657_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ components:
name: "no valid value",
value: "ABCDE",
checkErr: func(t require.TestingT, err error, i ...any) {
require.ErrorContains(t, err, "doesn't match schema due to: minimum string length is 10")
require.ErrorContains(t, err, "minimum string length is 10")

wErr := &openapi3.MultiError{}
require.ErrorAs(t, err, wErr)
Expand Down
2 changes: 1 addition & 1 deletion openapi3/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ func (schema *Schema) visitXOFOperations(settings *schemaValidationSettings, val
e.Origin = ErrOneOfConflict
e.Reason = fmt.Sprintf(`value matches more than one schema from "oneOf" (matches schemas at indices %v)`, matchedOneOfIndices)
} else {
e.Origin = fmt.Errorf("doesn't match schema due to: %w", validationErrors)
e.Origin = validationErrors
e.Reason = `value doesn't match any schema from "oneOf"`
}

Expand Down
6 changes: 3 additions & 3 deletions openapi3/schema_issue940_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ func TestOneOfErrorPreserved(t *testing.T) {

require.Equal(t, "oneOf", schemaErr.SchemaField)
require.Equal(t, `value doesn't match any schema from "oneOf"`, schemaErr.Reason)
require.Equal(t, `Error at "/foo": doesn't match schema due to: value must be a number Or value must be a string`, schemaErr.Error())
require.Equal(t, `Error at "/foo": value must be a number Or value must be a string`, schemaErr.Error())

var me multiErrorForOneOf
ok = errors.As(err, &me)
require.True(t, ok)
require.Equal(t, `Error at "/foo": value must be a number`, me[0].Error())
require.Equal(t, `Error at "/foo": value must be a string`, me[1].Error())
require.Equal(t, `value must be a number`, me[0].Error())
require.Equal(t, `value must be a string`, me[1].Error())
}
4 changes: 2 additions & 2 deletions openapi3/schema_oneOf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ func TestVisitJSON_OneOf_MissingField(t *testing.T) {
"name": "snoopy",
"$type": "dog",
})
require.ErrorContains(t, err, `doesn't match schema due to: Error at "/barks": property "barks" is missing`)
require.ErrorContains(t, err, `Error at "/barks": property "barks" is missing`)
}

func TestVisitJSON_OneOf_NoDescriptor_MissingField(t *testing.T) {
doc := oneofNoDiscriminatorSpec(t)
err := doc.Components.Schemas["Animal"].Value.VisitJSON(map[string]any{
"name": "snoopy",
})
require.ErrorContains(t, err, `doesn't match schema due to: Error at "/scratches": property "scratches" is missing`)
require.ErrorContains(t, err, `Error at "/scratches": property "scratches" is missing`)
}

func TestVisitJSON_OneOf_BadDiscriminatorType(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion openapi3filter/issue789_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ paths:
name: "failed oneof string pattern match",
spec: oneOfArraySpec,
req: `/items?test=def`,
errStr: `parameter "test" in query has an error: doesn't match schema due to: string doesn't match the regular expression`,
errStr: `parameter "test" in query has an error: string doesn't match the regular expression`,
},
{
name: "failed oneof string pattern match",
Expand Down
Loading