Skip to content

Commit e65aa1b

Browse files
authored
Merge pull request #700 from postmanlabs/feature/fix-response-code-issue
Fixed an issue where default responses were causing the validation to go into a loop
2 parents 58d2e27 + 880ac00 commit e65aa1b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libV2/validationUtils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,7 @@ function checkResponses (context, transaction, transactionPathPrefix, schemaPath
23712371
// for each response, find the appropriate response from schemaPath, and then validate response body and headers
23722372
async.map(responses, (response, responseCallback) => {
23732373
let thisResponseCode = _.toString(response.code),
2374-
thisSchemaResponse = _.get(schemaPath, ['responses', thisResponseCode]),
2374+
thisSchemaResponse = _.get(schemaPath, ['responses', thisResponseCode], _.get(schemaPath, 'responses.default')),
23752375
responsePathPrefix = thisResponseCode;
23762376

23772377
// X can be used as wild card character, so response code like 2XX in definition are valid
@@ -2449,6 +2449,8 @@ function checkResponses (context, transaction, transactionPathPrefix, schemaPath
24492449
missingResponses = [];
24502450

24512451
_.each(_.get(schemaPath, 'responses'), (responseObj, responseCode) => {
2452+
responseCode = responseCode === 'default' ? '500' : responseCode;
2453+
24522454
if (!_.includes(matchedResponses, responseCode)) {
24532455
let mismatchObj = {
24542456
property: 'RESPONSE',

0 commit comments

Comments
 (0)