@@ -133,7 +133,7 @@ function hash(input) {
133
133
*/
134
134
function verifyDeprecatedProperties ( resolvedSchema , includeDeprecated ) {
135
135
traverseUtility ( resolvedSchema . properties ) . forEach ( function ( property ) {
136
- if ( property ) {
136
+ if ( property && typeof property === 'object' ) {
137
137
if ( property . deprecated === true && includeDeprecated === false ) {
138
138
this . delete ( ) ;
139
139
}
@@ -151,20 +151,21 @@ function verifyDeprecatedProperties(resolvedSchema, includeDeprecated) {
151
151
* @param {string } parameterSourceOption Specifies whether the schema being faked is from a request or response.
152
152
* @param {* } components list of predefined components (with schemas)
153
153
* @param {string } schemaFormat default or xml
154
- * @param {string } indentCharacter char for 1 unit of indentation
155
- * @param {object } schemaCache - object storing schemaFaker and schmeResolution caches
156
- * @param {object } stackLimit - The depth to which schema resolution will happen for nested refs
157
- * @param {boolean } includeDeprecated - Whether to include the deprecated properties
154
+ * @param {object } schemaCache - object storing schemaFaker and schemaResolution caches
155
+ * @param {object } options - a standard list of options that's globally passed around. Check options.js for more.
158
156
* @returns {object } fakedObject
159
157
*/
160
158
function safeSchemaFaker ( oldSchema , resolveTo , resolveFor , parameterSourceOption , components ,
161
- schemaFormat , indentCharacter , schemaCache , stackLimit , includeDeprecated ) {
159
+ schemaFormat , schemaCache , options ) {
162
160
var prop , key , resolvedSchema , fakedSchema ,
163
161
schemaResolutionCache = _ . get ( schemaCache , 'schemaResolutionCache' , { } ) ,
164
162
schemaFakerCache = _ . get ( schemaCache , 'schemaFakerCache' , { } ) ;
165
163
let concreteUtils = components && components . hasOwnProperty ( 'concreteUtils' ) ?
166
164
components . concreteUtils :
167
165
DEFAULT_SCHEMA_UTILS ;
166
+ const indentCharacter = _ . get ( options , 'indentCharacter' , ' ' ) ,
167
+ stackLimit = _ . get ( options , 'stackLimit' , 10 ) ,
168
+ includeDeprecated = _ . get ( options , 'includeDeprecated' , true ) ;
168
169
169
170
resolvedSchema = deref . resolveRefs ( oldSchema , parameterSourceOption , components , schemaResolutionCache ,
170
171
resolveFor , resolveTo , 0 , { } , stackLimit ) ;
@@ -237,8 +238,11 @@ function safeSchemaFaker(oldSchema, resolveTo, resolveFor, parameterSourceOption
237
238
* @returns {boolean } whether to add or not the deprecated operation
238
239
*/
239
240
function shouldAddDeprecatedOperation ( operation , options ) {
240
- return ! operation . deprecated ||
241
- ( operation . deprecated === true && options . includeDeprecated === true ) ;
241
+ if ( typeof operation === 'object' ) {
242
+ return ! operation . deprecated ||
243
+ ( operation . deprecated === true && options . includeDeprecated === true ) ;
244
+ }
245
+ return false ;
242
246
}
243
247
244
248
@@ -979,8 +983,7 @@ module.exports = {
979
983
980
984
fakedData = options . schemaFaker ?
981
985
safeSchemaFaker ( variable . schema || { } , options . requestParametersResolution , PROCESSING_TYPE . CONVERSION ,
982
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , options . indentCharacter , schemaCache ,
983
- options . stackLimit , options . includeDeprecated ) : '' ;
986
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) : '' ;
984
987
985
988
convertedPathVar = this . convertParamsWithStyle ( variable , fakedData , PARAMETER_SOURCE . REQUEST ,
986
989
components , schemaCache , options ) ;
@@ -1438,25 +1441,20 @@ module.exports = {
1438
1441
header : [ ] ,
1439
1442
path : [ ]
1440
1443
} ,
1441
- includeDeprecated = options . includeDeprecated !== undefined ?
1442
- options . includeDeprecated : true ;
1444
+ includeDeprecated = options . includeDeprecated !== false ;
1443
1445
1444
1446
_ . forEach ( localParams , ( param ) => {
1445
1447
tempParam = param ;
1446
- let shouldAddDeprecated = ( includeDeprecated ||
1448
+ let verifyAddDeprecated = ( includeDeprecated ||
1447
1449
includeDeprecated === false && tempParam . deprecated !== true ) ;
1448
- if ( tempParam . in === 'query' ) {
1449
- if ( shouldAddDeprecated ) {
1450
+ if ( verifyAddDeprecated ) {
1451
+ if ( tempParam . in === 'query' ) {
1450
1452
params . query . push ( tempParam ) ;
1451
1453
}
1452
- }
1453
- else if ( tempParam . in === 'header' ) {
1454
- if ( shouldAddDeprecated ) {
1454
+ else if ( tempParam . in === 'header' ) {
1455
1455
params . header . push ( tempParam ) ;
1456
1456
}
1457
- }
1458
- else if ( tempParam . in === 'path' ) {
1459
- if ( shouldAddDeprecated ) {
1457
+ else if ( tempParam . in === 'path' ) {
1460
1458
params . path . push ( tempParam ) ;
1461
1459
}
1462
1460
}
@@ -1584,8 +1582,7 @@ module.exports = {
1584
1582
}
1585
1583
// Do not fake the bodyData if the complexity is 10.
1586
1584
bodyData = safeSchemaFaker ( bodyObj . schema || { } , resolveTo , PROCESSING_TYPE . CONVERSION , parameterSourceOption ,
1587
- components , schemaFormat , indentCharacter , schemaCache , options . stackLimit ,
1588
- options . includeDeprecated ) ;
1585
+ components , schemaFormat , schemaCache , options ) ;
1589
1586
}
1590
1587
else {
1591
1588
// do not fake if the option is false
@@ -1651,9 +1648,7 @@ module.exports = {
1651
1648
// fake data generated
1652
1649
paramValue = options . schemaFaker ?
1653
1650
safeSchemaFaker ( param . schema , resolveTo , PROCESSING_TYPE . CONVERSION , PARAMETER_SOURCE . REQUEST ,
1654
- components , SCHEMA_FORMATS . DEFAULT , options . indentCharacter , schemaCache , options . stackLimit ,
1655
- options . includeDeprecated ) : '' ;
1656
- // paramType = param.schema.type;
1651
+ components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) : '' ;
1657
1652
1658
1653
if ( typeof paramValue === 'number' || typeof paramValue === 'boolean' ) {
1659
1654
// the SDK will keep the number-ness,
@@ -1678,7 +1673,7 @@ module.exports = {
1678
1673
} ,
1679
1674
1680
1675
/**
1681
- * Recursicely extracts key-value pair from deep objects.
1676
+ * Recursively extracts key-value pair from deep objects.
1682
1677
*
1683
1678
* @param {* } deepObject - Deep object
1684
1679
* @param {* } objectKey - key associated with deep object
@@ -1829,8 +1824,7 @@ module.exports = {
1829
1824
this . assignParameterExamples ( header ) ;
1830
1825
1831
1826
fakeData = safeSchemaFaker ( header . schema || { } , resolveTo , PROCESSING_TYPE . CONVERSION , parameterSource ,
1832
- components , SCHEMA_FORMATS . DEFAULT , options . indentCharacter , schemaCache , options . stackLimit ,
1833
- options . includeDeprecated ) ;
1827
+ components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ;
1834
1828
}
1835
1829
}
1836
1830
else {
@@ -2426,8 +2420,7 @@ module.exports = {
2426
2420
if ( ! variableStore [ element . name ] ) {
2427
2421
let fakedData = options . schemaFaker ?
2428
2422
safeSchemaFaker ( element . schema || { } , options . requestParametersResolution , PROCESSING_TYPE . CONVERSION ,
2429
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , options . indentCharacter , schemaCache ,
2430
- options . stackLimit , options . includeDeprecated ) : '' ,
2423
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) : '' ,
2431
2424
convertedPathVar = _ . get ( this . convertParamsWithStyle ( element , fakedData , PARAMETER_SOURCE . REQUEST ,
2432
2425
components , schemaCache , options ) , '[0]' , { } ) ;
2433
2426
@@ -3337,8 +3330,7 @@ module.exports = {
3337
3330
key : txnParamName ,
3338
3331
actualValue : valueToUse ,
3339
3332
suggestedValue : safeSchemaFaker ( openApiSchemaObj || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
3340
- parameterSourceOption , components , SCHEMA_FORMATS . DEFAULT , options . indentCharacter , schemaCache ,
3341
- options . stackLimit , options . includeDeprecated )
3333
+ parameterSourceOption , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options . includeDeprecated )
3342
3334
} ;
3343
3335
}
3344
3336
@@ -3354,8 +3346,7 @@ module.exports = {
3354
3346
let mismatchObj ,
3355
3347
suggestedValue ,
3356
3348
fakedValue = safeSchemaFaker ( openApiSchemaObj || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
3357
- parameterSourceOption , components , SCHEMA_FORMATS . DEFAULT , options . indentCharacter , schemaCache ,
3358
- options . stackLimit , options . includeDeprecated ) ;
3349
+ parameterSourceOption , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ;
3359
3350
3360
3351
// Show detailed validation mismatches for only request/response body
3361
3352
if ( options . detailedBlobValidation && needJsonMatching ) {
@@ -3634,8 +3625,7 @@ module.exports = {
3634
3625
suggestedValue : {
3635
3626
key : pathVar . name ,
3636
3627
value : safeSchemaFaker ( pathVar . schema || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
3637
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , options . indentCharacter , schemaCache ,
3638
- options . stackLimit , options . includeDeprecated ) ,
3628
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ,
3639
3629
description : this . getParameterDescription ( pathVar )
3640
3630
}
3641
3631
} ;
@@ -3928,8 +3918,7 @@ module.exports = {
3928
3918
suggestedValue : {
3929
3919
key : qp . name ,
3930
3920
value : safeSchemaFaker ( qp . schema || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
3931
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , options . indentCharacter , schemaCache ,
3932
- options . stackLimit , options . includeDeprecated ) ,
3921
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ,
3933
3922
description : this . getParameterDescription ( qp )
3934
3923
}
3935
3924
} ;
@@ -4185,8 +4174,7 @@ module.exports = {
4185
4174
suggestedValue : {
4186
4175
key : header . name ,
4187
4176
value : safeSchemaFaker ( header . schema || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
4188
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , options . indentCharacter , schemaCache ,
4189
- options . stackLimit , options . includeDeprecated ) ,
4177
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ,
4190
4178
description : this . getParameterDescription ( header )
4191
4179
}
4192
4180
} ;
@@ -4293,8 +4281,7 @@ module.exports = {
4293
4281
suggestedValue : {
4294
4282
key : header . name ,
4295
4283
value : safeSchemaFaker ( header . schema || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
4296
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , options . indentCharacter , schemaCache ,
4297
- options . stackLimit , options . includeDeprecated ) ,
4284
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ,
4298
4285
description : this . getParameterDescription ( header )
4299
4286
}
4300
4287
} ;
@@ -4506,8 +4493,7 @@ module.exports = {
4506
4493
suggestedValue : {
4507
4494
key : uParam . name ,
4508
4495
value : safeSchemaFaker ( uParam . schema || { } , 'example' , PROCESSING_TYPE . VALIDATION ,
4509
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , options . indentCharacter , schemaCache ,
4510
- options . stackLimit , options . includeDeprecated ) ,
4496
+ PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache , options ) ,
4511
4497
description : this . getParameterDescription ( uParam )
4512
4498
}
4513
4499
} ;
0 commit comments