Add schemaResolutionCache logic for validator functions

This commit is contained in:
shreys7
2020-01-21 13:41:33 +05:30
parent 88989dcc67
commit 4516c0adc8
2 changed files with 27 additions and 20 deletions

View File

@@ -243,7 +243,9 @@ class SchemaPack {
validateTransaction(transactions, callback) {
let schema = this.openapi,
componentsAndPaths,
options = this.computedOptions;
options = this.computedOptions,
schemaResolutionCache = this.schemaFakerCache;
if (!this.validated) {
return callback(new OpenApiErr('The schema must be validated before attempting conversion'));
@@ -303,23 +305,23 @@ class SchemaPack {
async.parallel({
path: function(cb) {
schemaUtils.checkPathVariables(matchedPath.pathVariables, '$.request.url', matchedPath.path,
componentsAndPaths, options, cb);
componentsAndPaths, options, schemaResolutionCache, cb);
},
queryparams: function(cb) {
schemaUtils.checkQueryParams(requestUrl, '$.request.url.query', matchedPath.path,
componentsAndPaths, options, cb);
componentsAndPaths, options, schemaResolutionCache, cb);
},
headers: function(cb) {
schemaUtils.checkRequestHeaders(transaction.request.header, '$.request.header', matchedPath.path,
componentsAndPaths, options, cb);
componentsAndPaths, options, schemaResolutionCache, cb);
},
requestBody: function(cb) {
schemaUtils.checkRequestBody(transaction.request.body, '$.request.body', matchedPath.jsonPath,
matchedPath.path, componentsAndPaths, options, cb);
matchedPath.path, componentsAndPaths, options, schemaResolutionCache, cb);
},
responses: function (cb) {
schemaUtils.checkResponses(transaction.response, '$.responses', matchedPath.jsonPath,
matchedPath.path, componentsAndPaths, options, cb);
matchedPath.path, componentsAndPaths, options, schemaResolutionCache, cb);
}
}, (err, result) => {
let allMismatches = _.concat(result.queryparams, result.headers, result.path, result.requestBody),