Skip to content

Commit a8e0a69

Browse files
committed
bug fix
1 parent e8a45bc commit a8e0a69

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

libV2/schemaUtils.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,46 +1257,40 @@ let QUERYPARAM = 'query',
12571257
switch (style) {
12581258
case 'form':
12591259
if (explode && _.isObject(paramValue)) {
1260-
const schemaProps = _.get(param, 'schema.properties', {}),
1261-
hasProps = _.isObject(schemaProps) && !_.isEmpty(schemaProps),
1262-
isArrayValue = _.isArray(paramValue);
1263-
1264-
// Free-form object: do not emit individual keys
1265-
if (!hasProps && !isArrayValue) {
1266-
return pmParams;
1267-
}
1268-
1269-
_.forEach(paramValue, (value, key) => {
1270-
if (isArrayValue) {
1260+
const isArrayValue = _.isArray(paramValue);
1261+
// Arrays: emit one entry per item with the parameter name
1262+
if (isArrayValue) {
1263+
_.forEach(paramValue, (value) => {
12711264
pmParams.push({
12721265
key: paramName,
12731266
value: (value === undefined ? '' : _.toString(value)),
12741267
description,
12751268
disabled
12761269
});
1277-
return;
1278-
}
1270+
});
1271+
return pmParams;
1272+
}
12791273

1280-
if (!_.has(schemaProps, key)) {
1274+
// Objects: emit all keys except those that are schema definition keys
1275+
const schemaKeys = Object.keys(_.get(param, 'schema', {}));
1276+
_.forEach(paramValue, (value, key) => {
1277+
if (schemaKeys.includes(key)) {
12811278
return;
12821279
}
1283-
12841280
pmParams.push({
12851281
key,
12861282
value: (value === undefined ? '' : _.toString(value)),
12871283
description,
12881284
disabled
12891285
});
12901286
});
1291-
12921287
return pmParams;
12931288
}
12941289

12951290
break;
12961291
case 'deepObject':
12971292
if (_.isObject(paramValue) && !_.isArray(paramValue)) {
12981293
let extractedParams = extractDeepObjectParams(paramValue, paramName);
1299-
13001294
_.forEach(extractedParams, (extractedParam) => {
13011295
pmParams.push({
13021296
key: extractedParam.key,

0 commit comments

Comments
 (0)