Merge pull request #314 from postmanlabs/feature/fix-explode-params

Fixed incorrect handling for explodable parameters for resolution schema.
This commit is contained in:
Vishal Shingala
2021-01-25 17:45:54 +05:30
committed by GitHub
2 changed files with 34 additions and 6 deletions

View File

@@ -1513,15 +1513,22 @@ module.exports = {
});
return pmParams;
}
// handle free-form parameter correctly
if (explode && (_.get(param, 'schema.type') === 'object') && _.isEmpty(_.get(param, 'schema.properties'))) {
return pmParams;
}
break;
case 'deepObject':
_.forOwn(paramValue, (value, key) => {
pmParams.push({
key: param.name + '[' + key + ']',
value: (value === undefined ? '' : value),
description
if (_.isObject(paramValue)) {
_.forOwn(paramValue, (value, key) => {
pmParams.push({
key: param.name + '[' + key + ']',
value: (value === undefined ? '' : value),
description
});
});
});
}
return pmParams;
default:
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() {