Skip to content

Commit 1a717e8

Browse files
committed
added another nullcheck for responses
Signed-off-by: Dave Shanley <[email protected]>
1 parent 5c4680d commit 1a717e8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

responses/validate_body.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (v *responseBodyValidator) ValidateResponseBody(
4646

4747
// check if the response code is in the contract
4848
foundResponse := operation.Responses.FindResponseByCode(httpCode)
49-
if foundResponse != nil {
49+
if foundResponse != nil && foundResponse.Content != nil {
5050
// check content type has been defined in the contract
5151
if mediaType, ok := foundResponse.Content.Get(mediaTypeSting); ok {
5252
validationErrors = append(validationErrors,
@@ -64,7 +64,7 @@ func (v *responseBodyValidator) ValidateResponseBody(
6464
}
6565
} else {
6666
// no code match, check for default response
67-
if operation.Responses.Default != nil {
67+
if operation.Responses.Default != nil && operation.Responses.Default.Content != nil {
6868
// check content type has been defined in the contract
6969
if mediaType, ok := operation.Responses.Default.Content.Get(mediaTypeSting); ok {
7070
validationErrors = append(validationErrors,

0 commit comments

Comments
 (0)