Skip to content

Commit

Permalink
Merge pull request #1372 from apiaryio/1371-transaction-log-order
Browse files Browse the repository at this point in the history
fix: uses explicit validation result sections list for logging output
  • Loading branch information
artem-zakharchenko authored May 21, 2019
2 parents 3065284 + a2b8a0a commit a6cab86
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/TransactionRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,15 +573,18 @@ include a message body: https://tools.ietf.org/html/rfc7231#section-6.3\
let message = '';
const object = gavelResult || {};
let validatorOutput;
for (const sectionName of Object.keys(object || {})) {
// Section names are 'statusCode', 'headers', 'body' (and 'version', which is irrelevant)

// Order-sensitive list of validation sections to output in the log
const resultSections = ['headers', 'body', 'statusCode']
.filter(sectionName => Object.prototype.hasOwnProperty.call(object, sectionName));

resultSections.forEach((sectionName) => {
validatorOutput = object[sectionName];
if (sectionName !== 'version') {
for (const gavelError of validatorOutput.results || []) {
message += `${sectionName}: ${gavelError.message}\n`;
}
}
}
(validatorOutput.results || []).forEach((gavelError) => {
message += `${sectionName}: ${gavelError.message}\n`;
});
});

test.message = message;

// Record raw validation output to transaction results object
Expand Down

0 comments on commit a6cab86

Please sign in to comment.