|
3 | 3 | * utils.js contains other util functions
|
4 | 4 | */
|
5 | 5 |
|
6 |
| -const { formatDataPath, checkIsCorrectType, isKnownType, |
7 |
| - formatSchemaPathFromAJVErrorToConvertToDataPath } = require('./common/schemaUtilsCommon.js'), |
| 6 | +const { formatDataPath, checkIsCorrectType, isKnownType } = require('./common/schemaUtilsCommon.js'), |
8 | 7 | { getConcreteSchemaUtils } = require('./common/versionUtils.js'),
|
9 | 8 | async = require('async'),
|
10 | 9 | sdk = require('postman-collection'),
|
@@ -1370,20 +1369,19 @@ module.exports = {
|
1370 | 1369 | * @param {*} schema bodyObject (media type) schema to use
|
1371 | 1370 | * @param {*} example - Exampel took from the bodyObject
|
1372 | 1371 | * @param {object} components - components defined in the OAS spec.
|
| 1372 | + * @param {object} options - a standard list of options that's globally passed around. Check options.js for more. |
1373 | 1373 | * @returns {boolean} Wheter to use the property value of the example as the value of the
|
1374 | 1374 | * body data
|
1375 | 1375 | */
|
1376 |
| - useExampleValuePropAsValue(schema, example, components) { |
| 1376 | + useExampleValuePropAsValue(schema, example, components, options) { |
1377 | 1377 | let schemaProperties = [],
|
1378 | 1378 | schemaObject,
|
1379 |
| - schemaDataPath = '', |
1380 | 1379 | exampleProperties = [];
|
1381 | 1380 | if (!schema) {
|
1382 | 1381 | return true;
|
1383 | 1382 | }
|
1384 |
| - if (schema.$ref) { |
1385 |
| - schemaDataPath = formatDataPath(formatSchemaPathFromAJVErrorToConvertToDataPath(schema.$ref)); |
1386 |
| - schemaObject = _.get(components, schemaDataPath); |
| 1383 | + if (schema.hasOwnProperty('$ref')) { |
| 1384 | + schemaObject = this.getRefObject(schema.$ref, components, options); |
1387 | 1385 | }
|
1388 | 1386 | else {
|
1389 | 1387 | schemaObject = schema;
|
@@ -1445,7 +1443,7 @@ module.exports = {
|
1445 | 1443 | bodyData = bodyObj.example;
|
1446 | 1444 | // return example value if present else example is returned
|
1447 | 1445 | if (bodyData.hasOwnProperty('value') &&
|
1448 |
| - this.useExampleValuePropAsValue(bodyObj.schema, bodyObj.example, components)) { |
| 1446 | + this.useExampleValuePropAsValue(bodyObj.schema, bodyObj.example, components, options)) { |
1449 | 1447 | bodyData = bodyData.value;
|
1450 | 1448 | }
|
1451 | 1449 | }
|
|
0 commit comments