From f95435749c5c7f9af14979093bd53d761276230b Mon Sep 17 00:00:00 2001 From: Vishal Shingala Date: Fri, 19 Feb 2021 10:34:55 +0530 Subject: [PATCH] Added handling to report missing in collection mismatch only for required properties --- lib/schemaUtils.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/schemaUtils.js b/lib/schemaUtils.js index c0fa248..a22e8a1 100644 --- a/lib/schemaUtils.js +++ b/lib/schemaUtils.js @@ -3831,6 +3831,10 @@ module.exports = { _.has(encodingValue, 'explode') && (resolvedProp.explode = encodingValue.explode); } + if (_.includes(_.get(urlencodedBodySchema, 'required'), propName)) { + resolvedProp.required = true; + } + pSerialisationInfo = this.getParamSerialisationInfo(resolvedProp, PARAMETER_SOURCE.REQUEST, components, schemaCache); isPropSeparable = _.includes(['form', 'deepObject'], pSerialisationInfo.style); @@ -3929,7 +3933,8 @@ module.exports = { }); _.each(resolvedSchemaParams, (uParam) => { - if (!_.find(requestBody.urlencoded, (param) => { return param.key === uParam.name; })) { + // report mismatches only for reuired properties + if (!_.find(requestBody.urlencoded, (param) => { return param.key === uParam.name; }) && uParam.required) { mismatchObj = { property: mismatchProperty, transactionJsonPath: transactionPathPrefix + '.urlencoded',