@@ -64,7 +64,6 @@ const _ = require('lodash'),
64
64
'accept' ,
65
65
'authorization'
66
66
] ,
67
- DEFAULT_SCHEMA_UTILS = require ( '../lib/30XUtils/schemaUtils30X' ) ,
68
67
69
68
OAS_NOT_SUPPORTED = '<Error: Not supported in OAS>' ,
70
69
@@ -133,24 +132,23 @@ function shouldAddDeprecatedOperation (operation, options) {
133
132
* removes things that might make schemaFaker crash
134
133
* @param {Object } context - Required context from related SchemaPack function
135
134
* @param {* } oldSchema the schema to fake
136
- * @param {string } resolveTo The desired JSON-generation mechanism (schema: prefer using the JSONschema to
137
135
* generate a fake object, example: use specified examples as-is). Default: schema
138
136
* @param {* } resolveFor - resolve refs for flow validation/conversion (value to be one of VALIDATION/CONVERSION)
139
137
* @param {string } parameterSourceOption Specifies whether the schema being faked is from a request or response.
140
138
* @param {* } components list of predefined components (with schemas)
141
139
* @param {string } schemaFormat default or xml
142
140
* @param {object } schemaCache - object storing schemaFaker and schemaResolution caches
143
- * @param {object } options - a standard list of options that's globally passed around. Check options.js for more.
144
141
* @returns {object } fakedObject
145
142
*/
146
- function safeSchemaFaker ( context , oldSchema , resolveTo , resolveFor , parameterSourceOption , components ,
147
- schemaFormat , schemaCache , options ) {
148
- var prop , key , resolvedSchema , fakedSchema ,
149
- schemaFakerCache = _ . get ( schemaCache , 'schemaFakerCache' , { } ) ;
150
- let concreteUtils = components && components . hasOwnProperty ( 'concreteUtils' ) ?
151
- components . concreteUtils :
152
- DEFAULT_SCHEMA_UTILS ;
153
- const indentCharacter = options . indentCharacter ;
143
+ function safeSchemaFaker ( context , oldSchema , resolveFor , parameterSourceOption , components ,
144
+ schemaFormat , schemaCache ) {
145
+ let prop , key , resolvedSchema , fakedSchema ,
146
+ schemaFakerCache = _ . get ( schemaCache , 'schemaFakerCache' , { } ) ,
147
+ concreteUtils = context . concreteUtils ;
148
+
149
+ const options = context . computedOptions ,
150
+ resolveTo = _ . get ( options , 'parametersResolution' , 'example' ) ,
151
+ indentCharacter = options . indentCharacter ;
154
152
155
153
resolvedSchema = resolveSchema ( context , oldSchema , 0 , PROCESSING_TYPE . VALIDATION ) ;
156
154
@@ -1426,8 +1424,8 @@ function checkValueAgainstSchema (context, property, jsonPathPrefix, txnParamNam
1426
1424
mismatchObj . suggestedFix = {
1427
1425
key : txnParamName ,
1428
1426
actualValue : valueToUse ,
1429
- suggestedValue : safeSchemaFaker ( context , openApiSchemaObj || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
1430
- parameterSourceOption , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options . includeDeprecated )
1427
+ suggestedValue : safeSchemaFaker ( context , openApiSchemaObj || { } , PROCESSING_TYPE . VALIDATION ,
1428
+ parameterSourceOption , components , SCHEMA_FORMATS . DEFAULT , schemaCache )
1431
1429
} ;
1432
1430
}
1433
1431
@@ -1442,8 +1440,8 @@ function checkValueAgainstSchema (context, property, jsonPathPrefix, txnParamNam
1442
1440
if ( ! _ . isEmpty ( filteredValidationError ) ) {
1443
1441
let mismatchObj ,
1444
1442
suggestedValue ,
1445
- fakedValue = safeSchemaFaker ( context , openApiSchemaObj || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
1446
- parameterSourceOption , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ;
1443
+ fakedValue = safeSchemaFaker ( context , openApiSchemaObj || { } , PROCESSING_TYPE . VALIDATION ,
1444
+ parameterSourceOption , components , SCHEMA_FORMATS . DEFAULT , schemaCache ) ;
1447
1445
1448
1446
// Show detailed validation mismatches for only request/response body
1449
1447
if ( options . detailedBlobValidation && needJsonMatching ) {
@@ -1703,8 +1701,8 @@ function checkPathVariables (context, matchedPathData, transactionPathPrefix, sc
1703
1701
actualValue,
1704
1702
suggestedValue : {
1705
1703
key : pathVar . name ,
1706
- value : safeSchemaFaker ( context , pathVar . schema || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
1707
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ,
1704
+ value : safeSchemaFaker ( context , pathVar . schema || { } , PROCESSING_TYPE . VALIDATION ,
1705
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache ) ,
1708
1706
description : getParameterDescription ( pathVar )
1709
1707
}
1710
1708
} ;
@@ -1841,8 +1839,8 @@ function checkQueryParams (context, queryParams, transactionPathPrefix, schemaPa
1841
1839
actualValue : null ,
1842
1840
suggestedValue : {
1843
1841
key : qp . name ,
1844
- value : safeSchemaFaker ( context , qp . schema || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
1845
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ,
1842
+ value : safeSchemaFaker ( context , qp . schema || { } , PROCESSING_TYPE . VALIDATION ,
1843
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache ) ,
1846
1844
description : getParameterDescription ( qp )
1847
1845
}
1848
1846
} ;
@@ -1963,8 +1961,8 @@ function checkRequestHeaders (context, headers, transactionPathPrefix, schemaPat
1963
1961
actualValue : null ,
1964
1962
suggestedValue : {
1965
1963
key : header . name ,
1966
- value : safeSchemaFaker ( context , header . schema || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
1967
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ,
1964
+ value : safeSchemaFaker ( context , header . schema || { } , PROCESSING_TYPE . VALIDATION ,
1965
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache ) ,
1968
1966
description : getParameterDescription ( header )
1969
1967
}
1970
1968
} ;
@@ -2081,8 +2079,8 @@ function checkResponseHeaders (context, schemaResponse, headers, transactionPath
2081
2079
actualValue : null ,
2082
2080
suggestedValue : {
2083
2081
key : header . name ,
2084
- value : safeSchemaFaker ( context , header . schema || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
2085
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ,
2082
+ value : safeSchemaFaker ( context , header . schema || { } , PROCESSING_TYPE . VALIDATION ,
2083
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache ) ,
2086
2084
description : getParameterDescription ( header )
2087
2085
}
2088
2086
} ;
@@ -2251,8 +2249,8 @@ function checkRequestBody (context, requestBody, transactionPathPrefix, schemaPa
2251
2249
actualValue : null ,
2252
2250
suggestedValue : {
2253
2251
key : uParam . name ,
2254
- value : safeSchemaFaker ( context , uParam . schema || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
2255
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ,
2252
+ value : safeSchemaFaker ( context , uParam . schema || { } , PROCESSING_TYPE . VALIDATION ,
2253
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache ) ,
2256
2254
description : getParameterDescription ( uParam )
2257
2255
}
2258
2256
} ;
0 commit comments