Fixed incorrect handling for explodable parameters for resolution schema

This commit is contained in:
Vishal Shingala
2020-12-04 00:41:51 +05:30
parent 07587723c1
commit d3ac1261d0
2 changed files with 34 additions and 6 deletions

View File

@@ -1483,8 +1483,14 @@ module.exports = {
}); });
return pmParams; return pmParams;
} }
// handle free-form parameter correctly
if (explode && (_.get(param, 'schema.type') === 'object') && _.isEmpty(_.get(param, 'schema.properties'))) {
return pmParams;
}
break; break;
case 'deepObject': case 'deepObject':
if (_.isObject(paramValue)) {
_.forOwn(paramValue, (value, key) => { _.forOwn(paramValue, (value, key) => {
pmParams.push({ pmParams.push({
key: param.name + '[' + key + ']', key: param.name + '[' + key + ']',
@@ -1492,6 +1498,7 @@ module.exports = {
description description
}); });
}); });
}
return pmParams; return pmParams;
default: default:
break; break;

View File

@@ -1483,6 +1483,27 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
}); });
}); });
}); });
describe('Should convert queryParam with schema {type:object, properties: undefined, explode: true, ', function() {
let emptyObjParam = {
name: 'empty-obj',
in: 'query',
description: 'query param',
schema: { type: 'object' }
};
it('style:deepObject } to pm param', function (done) {
let pmParam = SchemaUtils.convertToPmQueryParameters(_.assign(emptyObjParam, { style: 'deepObject' }));
expect(pmParam).to.eql([]);
done();
});
it('style:form } to pm param', function (done) {
let pmParam = SchemaUtils.convertToPmQueryParameters(_.assign(emptyObjParam, { style: 'form' }));
expect(pmParam).to.eql([]);
done();
});
});
}); });
describe('convertToPmBody function', function() { describe('convertToPmBody function', function() {