Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed invalid transaction paths and changed REQUEST_BODY to BODY. #198

Merged
merged 3 commits into from
Apr 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/schemaUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const async = require('async'),
QUERYPARAM: 'query parameter',
PATHVARIABLE: 'path variable',
HEADER: 'header',
REQUEST_BODY: 'request body',
BODY: 'request body',
RESPONSE_HEADER: 'response header',
RESPONSE_BODY: 'response body'
},
Expand Down Expand Up @@ -1956,7 +1956,7 @@ module.exports = {

/**
*
* @param {*} property - one of QUERYPARAM, PATHVARIABLE, HEADER, REQUEST_BODY, RESPONSE_HEADER, RESPONSE_BODY
* @param {*} property - one of QUERYPARAM, PATHVARIABLE, HEADER, BODY, RESPONSE_HEADER, RESPONSE_BODY
* @param {*} jsonPathPrefix - this will be prepended to all JSON schema paths on the request
* @param {*} txnParamName - Optional - The name of the param being validated (useful for query params,
* req headers, res headers)
Expand Down Expand Up @@ -2371,7 +2371,7 @@ module.exports = {
mismatches.push({
property: mismatchProperty,
transactionJsonPath: transactionPathPrefix + '/' + pHeader.key,
schemaJsonPath: schemaPathPrefix + '/headers',
schemaJsonPath: schemaPathPrefix + '.headers',
reasonCode: 'MISSING_IN_SCHEMA',
reason: `The header ${pHeader.key} was not found in the schema`
});
Expand Down Expand Up @@ -2451,7 +2451,7 @@ module.exports = {
mismatches.push({
property: mismatchProperty,
transactionJsonPath: transactionPathPrefix,
schemaJsonPath: schemaPathPrefix + 'requestBody.content.application.json.schema',
schemaJsonPath: schemaPathPrefix + '.requestBody.content[application/json].schema',
reasonCode: 'INVALID_BODY',
reason: 'The request body didn\'t match the specified schema'
});
Expand All @@ -2460,9 +2460,9 @@ module.exports = {
// _.each(validate.errors, (error) => {
// // error.keyword can be https://ajv.js.org/keywords.html
// mismatches.push({
// property: 'REQUEST_BODY',
// property: 'BODY',
// transactionJsonPath: transactionPathPrefix + error.dataPath,
// schemaJsonPath: schemaPathPrefix + 'requestBody.content.application.json.schema.' + error.schemaPath,
// schemaJsonPath: schemaPathPrefix + '.requestBody.content[application/json].schema.' + error.schemaPath,
// reasonCode: error.keyword.toUpperCase(),
// reason: error.message
// });
Expand Down Expand Up @@ -2500,7 +2500,7 @@ module.exports = {
setTimeout(() => {
return this.checkValueAgainstSchema(mismatchProperty,
transactionPathPrefix,
null, // no param name for the request body
null, // no param name for the response body
body,
schemaPathPrefix + '.content[application/json].schema',
deref.resolveRefs(schemaContent, 'response', components, schemaResolutionCache,
Expand Down Expand Up @@ -2538,13 +2538,13 @@ module.exports = {
async.parallel({
headers: (cb) => {
this.checkResponseHeaders(thisSchemaResponse, response.header,
transactionPathPrefix + '[' + response.id + ']header',
transactionPathPrefix + '[' + response.id + '].header',
schemaPathPrefix + '.responses.' + responsePathPrefix, components, options, schemaResolutionCache, cb);
},
body: (cb) => {
// assume it's JSON at this point
this.checkResponseBody(thisSchemaResponse, response.body,
transactionPathPrefix + '[' + response.id + ']body',
transactionPathPrefix + '[' + response.id + '].body',
schemaPathPrefix + '.responses.' + responsePathPrefix, components, options, schemaResolutionCache, cb);
}
}, (err, result) => {
Expand Down