Skip to content

Commit

Permalink
Tuned up validation
Browse files Browse the repository at this point in the history
The correct lookup is being used now and there is more noise reduction.

Signed-off-by: Dave Shanley <[email protected]>
  • Loading branch information
daveshanley committed Sep 16, 2023
1 parent 8f397fa commit 8b01e92
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions schema_validation/validate_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ func ValidateOpenAPIDocument(doc libopenapi.Document) (bool, []*errors.Validatio

for q := range schFlatErrs {
er := schFlatErrs[q]
if er.KeywordLocation == "" || strings.HasPrefix(er.Error, "doesn't validate with") {
if er.KeywordLocation == "" ||
strings.HasPrefix(er.Error, "oneOf failed") ||
strings.HasPrefix(er.Error, "allOf failed") ||
strings.HasPrefix(er.Error, "anyOf failed") ||
strings.HasPrefix(er.Error, "if failed") ||
strings.HasPrefix(er.Error, "else failed") ||
strings.HasPrefix(er.Error, "doesn't validate with") {
continue // ignore this error, it's useless tbh, utter noise.
}
if er.Error != "" {

// locate the violated property in the schema
located := LocateSchemaPropertyNodeByJSONPath(info.RootNode.Content[0], er.KeywordLocation)
if located == nil {
// try again with the instance location
located = LocateSchemaPropertyNodeByJSONPath(info.RootNode.Content[0], er.InstanceLocation)
}
located := LocateSchemaPropertyNodeByJSONPath(info.RootNode.Content[0], er.InstanceLocation)
violation := &errors.SchemaValidationFailure{
Reason: er.Error,
Location: er.InstanceLocation,
Expand Down

0 comments on commit 8b01e92

Please sign in to comment.