Validation bugfixes

This commit is contained in:
Abhijit Kane
2020-01-03 15:10:01 +05:30
parent 0f4da23e83
commit 84284a7a82

View File

@@ -2199,18 +2199,21 @@ module.exports = {
if (!schemaContent) { if (!schemaContent) {
// no specific or default response with application/json // no specific or default response with application/json
return callback(null, [{ // return callback(null, [{
property: mismatchProperty, // property: mismatchProperty,
transactionJsonPath: transactionPathPrefix, // transactionJsonPath: transactionPathPrefix,
schemaJsonPath: null, // schemaJsonPath: null,
reasonCode: 'BODY_SCHEMA_NOT_FOUND', // reasonCode: 'BODY_SCHEMA_NOT_FOUND',
reason: 'No application/json schema found for this response' // reason: 'No JSON schema found for this response'
}]); // }]);
// cannot show mismatches if the schema didn't have any application/JSON response
return callback(null, []);
} }
setTimeout(() => { setTimeout(() => {
return this.checkValueAgainstSchema(mismatchProperty, return this.checkValueAgainstSchema(mismatchProperty,
transactionPathPrefix + '.body', transactionPathPrefix,
body, body,
schemaPathPrefix + '.content[application/json].schema', schemaPathPrefix + '.content[application/json].schema',
deref.resolveRefs(schemaContent, 'response', components), deref.resolveRefs(schemaContent, 'response', components),
@@ -2252,7 +2255,7 @@ module.exports = {
body: (cb) => { body: (cb) => {
// assume it's JSON at this point // assume it's JSON at this point
this.checkResponseBody(thisSchemaResponse, response.body, this.checkResponseBody(thisSchemaResponse, response.body,
transactionPathPrefix + '.' + response.id + '.body', transactionPathPrefix + '[' + response.id + ']body',
schemaPathPrefix + '.responses.' + responsePathPrefix, components, options, cb); schemaPathPrefix + '.responses.' + responsePathPrefix, components, options, cb);
} }
}, (err, result) => { }, (err, result) => {