Skip to content

Commit dca35f7

Browse files
committed
Fix bug with response validation.
Signed-off-by: Dave Shanley <[email protected]>
1 parent 64f44a5 commit dca35f7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

responses/validate_response.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ func ValidateResponseSchema(
123123
}
124124
}
125125

126+
line := 0
127+
col := 0
128+
if schema.GoLow().Type.KeyNode != nil {
129+
line = schema.GoLow().Type.KeyNode.Line
130+
col = schema.GoLow().Type.KeyNode.Column
131+
}
132+
133+
126134
// add the error to the list
127135
validationErrors = append(validationErrors, &errors.ValidationError{
128136
ValidationType: helpers.ResponseBodyValidation,
@@ -131,8 +139,8 @@ func ValidateResponseSchema(
131139
response.StatusCode, request.URL.Path),
132140
Reason: fmt.Sprintf("The response body for status code '%d' is defined as an object. "+
133141
"However, it does not meet the schema requirements of the specification", response.StatusCode),
134-
SpecLine: schema.GoLow().Type.KeyNode.Line,
135-
SpecCol: schema.GoLow().Type.KeyNode.Column,
142+
SpecLine: line,
143+
SpecCol: col,
136144
SchemaValidationErrors: schemaValidationErrors,
137145
HowToFix: errors.HowToFixInvalidSchema,
138146
Context: string(renderedSchema), // attach the rendered schema to the error

0 commit comments

Comments
 (0)