Merge pull request #266 from postmanlabs/feature/fix-empty-collectionvar-value

Fixed issue where collection variable generated for path variables had empty values.
This commit is contained in:
Vishal Shingala
2020-08-06 12:42:33 +05:30
committed by GitHub
3 changed files with 47 additions and 33 deletions

View File

@@ -1906,12 +1906,14 @@ module.exports = {
// Add collection variables to the variableStore.
sanitizeResult.collectionVars.forEach((element) => {
if (!variableStore[element.name]) {
variableStore[element.name] = {
id: element.name,
value: element.default || '',
description: element.description,
type: 'collection'
};
let fakedData = options.schemaFaker ?
safeSchemaFaker(element.schema || {}, options.requestParametersResolution, PROCESSING_TYPE.CONVERSION,
PARAMETER_SOURCE.REQUEST, components, SCHEMA_FORMATS.DEFAULT, options.indentCharacter, schemaCache,
options.stackLimit) : '',
convertedPathVar = _.get(this.convertParamsWithStyle(element, fakedData, PARAMETER_SOURCE.REQUEST,
components, schemaCache), '[0]', {});
variableStore[element.name] = _.assign(convertedPathVar, { id: element.name, type: 'collection' });
}
});
// accounting for the overriding of the root level and path level servers object if present at the operation level
@@ -3863,7 +3865,7 @@ module.exports = {
// Not adding colloection variables for now
suggestedValue: {
request: convertedRequest,
variables
variables: _.values(variables)
}
};
}