Skip to content

Commit

Permalink
Fix bug with response validation.
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Shanley <dave@quobix.com>
  • Loading branch information
daveshanley committed Aug 1, 2023
1 parent 64f44a5 commit dca35f7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions responses/validate_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ func ValidateResponseSchema(
}
}

line := 0
col := 0
if schema.GoLow().Type.KeyNode != nil {
line = schema.GoLow().Type.KeyNode.Line
col = schema.GoLow().Type.KeyNode.Column
}


// add the error to the list
validationErrors = append(validationErrors, &errors.ValidationError{
ValidationType: helpers.ResponseBodyValidation,
Expand All @@ -131,8 +139,8 @@ func ValidateResponseSchema(
response.StatusCode, request.URL.Path),
Reason: fmt.Sprintf("The response body for status code '%d' is defined as an object. "+
"However, it does not meet the schema requirements of the specification", response.StatusCode),
SpecLine: schema.GoLow().Type.KeyNode.Line,
SpecCol: schema.GoLow().Type.KeyNode.Column,
SpecLine: line,
SpecCol: col,
SchemaValidationErrors: schemaValidationErrors,
HowToFix: errors.HowToFixInvalidSchema,
Context: string(renderedSchema), // attach the rendered schema to the error
Expand Down

0 comments on commit dca35f7

Please sign in to comment.