diff --git a/lib/schemaUtils.js b/lib/schemaUtils.js index 6cad6234f..5049dec5d 100644 --- a/lib/schemaUtils.js +++ b/lib/schemaUtils.js @@ -761,13 +761,21 @@ module.exports = { } else { _.forEach(commonPathVars, (variable) => { - let description = this.getParameterDescription(variable); + let description = this.getParameterDescription(variable), + paramValue = options.schemaFaker ? + safeSchemaFaker(variable.schema || {}, 'schema', components, 'REQUEST', + SCHEMA_FORMATS.DEFAULT, options.indentCharacter, schemaCache) : ''; + + // Use path variable example value as param value + // Reference to https://github.com/postmanlabs/openapi-to-postman/issues/204 + if (options.requestParametersResolution === 'example' && variable.schema && variable.schema.example) { + paramValue = variable.schema.example; + } + variables.push({ key: variable.name, // we only fake the schema for param-level pathVars - value: options.schemaFaker ? - safeSchemaFaker(variable.schema || {}, 'schema', components, 'REQUEST', - SCHEMA_FORMATS.DEFAULT, options.indentCharacter, schemaCache) : '', + value: paramValue, description: description }); });