Fixed issue where validation was giving INVALID_TYPE instead of MISSING_IN_REQUEST if path variable is not present in transaction

This commit is contained in:
Vishal Shingala
2021-10-05 13:01:39 +05:30
parent b6c51c1824
commit e6b3bb464d
2 changed files with 10 additions and 1 deletions

View File

@@ -3233,6 +3233,11 @@ module.exports = {
return cb(null, mismatches);
}
// don't validate variable if not present in transaction
if (!pathVar._varMatched) {
return cb(null, mismatches);
}
// assign parameter example(s) as schema examples
this.assignParameterExamples(schemaPathVar);
@@ -3264,7 +3269,9 @@ module.exports = {
// go through required schemaPathVariables, and params that aren't found in the given transaction are errors
_.each(schemaPathVariables, (pathVar) => {
if (!_.find(determinedPathVariables, (param) => { return param.key === pathVar.name; })) {
if (!_.find(determinedPathVariables, (param) => {
return param.key === pathVar.name && param._varMatched;
})) {
// assign parameter example(s) as schema examples;
this.assignParameterExamples(pathVar);