Skip to content

Commit 8b01e92

Browse files
committed
Tuned up validation
The correct lookup is being used now and there is more noise reduction. Signed-off-by: Dave Shanley <[email protected]>
1 parent 8f397fa commit 8b01e92

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

schema_validation/validate_document.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,19 @@ func ValidateOpenAPIDocument(doc libopenapi.Document) (bool, []*errors.Validatio
4040

4141
for q := range schFlatErrs {
4242
er := schFlatErrs[q]
43-
if er.KeywordLocation == "" || strings.HasPrefix(er.Error, "doesn't validate with") {
43+
if er.KeywordLocation == "" ||
44+
strings.HasPrefix(er.Error, "oneOf failed") ||
45+
strings.HasPrefix(er.Error, "allOf failed") ||
46+
strings.HasPrefix(er.Error, "anyOf failed") ||
47+
strings.HasPrefix(er.Error, "if failed") ||
48+
strings.HasPrefix(er.Error, "else failed") ||
49+
strings.HasPrefix(er.Error, "doesn't validate with") {
4450
continue // ignore this error, it's useless tbh, utter noise.
4551
}
4652
if er.Error != "" {
4753

4854
// locate the violated property in the schema
49-
located := LocateSchemaPropertyNodeByJSONPath(info.RootNode.Content[0], er.KeywordLocation)
50-
if located == nil {
51-
// try again with the instance location
52-
located = LocateSchemaPropertyNodeByJSONPath(info.RootNode.Content[0], er.InstanceLocation)
53-
}
55+
located := LocateSchemaPropertyNodeByJSONPath(info.RootNode.Content[0], er.InstanceLocation)
5456
violation := &errors.SchemaValidationFailure{
5557
Reason: er.Error,
5658
Location: er.InstanceLocation,

0 commit comments

Comments
 (0)