@@ -159,7 +159,10 @@ function safeSchemaFaker (context, oldSchema, resolveFor, parameterSourceOption,
159
159
* i.e. For array it'll add maxItems = 2. This should be avoided as we'll again be needing non-mutated schema
160
160
* in further VALIDATION use cases as needed.
161
161
*/
162
- resolvedSchema = resolveSchema ( context , _ . cloneDeep ( oldSchema ) , 0 , _ . toLower ( PROCESSING_TYPE . CONVERSION ) ) ;
162
+ resolvedSchema = resolveSchema ( context , _ . cloneDeep ( oldSchema ) , {
163
+ resolveFor : _ . toLower ( PROCESSING_TYPE . CONVERSION ) ,
164
+ isResponseSchema : parameterSourceOption === PARAMETER_SOURCE . RESPONSE
165
+ } ) ;
163
166
164
167
resolvedSchema = concreteUtils . fixExamplesByVersion ( resolvedSchema ) ;
165
168
key = JSON . stringify ( resolvedSchema ) ;
@@ -404,8 +407,10 @@ function getParameterDescription (parameter) {
404
407
*/
405
408
function getParamSerialisationInfo ( param , parameterSource , components , options ) {
406
409
var paramName = _ . get ( param , 'name' ) ,
407
- paramSchema = resolveSchema ( getDefaultContext ( options , components ) , _ . cloneDeep ( param . schema ) ,
408
- 0 , PROCESSING_TYPE . VALIDATION ) ,
410
+ paramSchema = resolveSchema ( getDefaultContext ( options , components ) , _ . cloneDeep ( param . schema ) , {
411
+ resolveFor : PROCESSING_TYPE . VALIDATION ,
412
+ isResponseSchema : parameterSource === PARAMETER_SOURCE . RESPONSE
413
+ } ) ,
409
414
style , // style property defined/inferred from schema
410
415
explode , // explode property defined/inferred from schema
411
416
propSeparator , // separates two properties or values
@@ -494,8 +499,10 @@ function getParamSerialisationInfo (param, parameterSource, components, options)
494
499
*/
495
500
function deserialiseParamValue ( param , paramValue , parameterSource , components , options ) {
496
501
var constructedValue ,
497
- paramSchema = resolveSchema ( getDefaultContext ( options , components ) , _ . cloneDeep ( param . schema ) ,
498
- 0 , PROCESSING_TYPE . VALIDATION ) ,
502
+ paramSchema = resolveSchema ( getDefaultContext ( options , components ) , _ . cloneDeep ( param . schema ) , {
503
+ resolveFor : PROCESSING_TYPE . VALIDATION ,
504
+ isResponseSchema : parameterSource === PARAMETER_SOURCE . RESPONSE
505
+ } ) ,
499
506
isEvenNumber = ( num ) => {
500
507
return ( num % 2 === 0 ) ;
501
508
} ,
@@ -1335,7 +1342,10 @@ function checkValueAgainstSchema (context, property, jsonPathPrefix, txnParamNam
1335
1342
invalidJson = false ,
1336
1343
valueToUse = value ,
1337
1344
1338
- schema = resolveSchema ( context , openApiSchemaObj , 0 , PROCESSING_TYPE . VALIDATION ) ,
1345
+ schema = resolveSchema ( context , openApiSchemaObj , {
1346
+ resolveFor : PROCESSING_TYPE . VALIDATION ,
1347
+ isResponseSchema : parameterSourceOption === PARAMETER_SOURCE . RESPONSE
1348
+ } ) ,
1339
1349
compositeSchema = schema . oneOf || schema . anyOf ,
1340
1350
compareTypes = _ . get ( context , 'concreteUtils.compareTypes' ) || concreteUtils . compareTypes ;
1341
1351
@@ -1711,7 +1721,9 @@ function checkPathVariables (context, matchedPathData, transactionPathPrefix, sc
1711
1721
} ;
1712
1722
1713
1723
if ( options . suggestAvailableFixes ) {
1714
- const resolvedSchema = resolveSchema ( context , pathVar . schema , 0 , PROCESSING_TYPE . VALIDATION ) ;
1724
+ const resolvedSchema = resolveSchema ( context , pathVar . schema , {
1725
+ resolveFor : PROCESSING_TYPE . VALIDATION
1726
+ } ) ;
1715
1727
1716
1728
mismatchObj . suggestedFix = {
1717
1729
key : pathVar . name ,
@@ -1758,8 +1770,9 @@ function checkQueryParams (context, queryParams, transactionPathPrefix, schemaPa
1758
1770
// below will make sure for exploded params actual schema of property present in collection is present
1759
1771
_ . forEach ( schemaParams , ( param ) => {
1760
1772
let pathPrefix = param . pathPrefix ,
1761
- paramSchema = resolveSchema ( context , _ . cloneDeep ( param . schema ) ,
1762
- 0 , PROCESSING_TYPE . VALIDATION ) ,
1773
+ paramSchema = resolveSchema ( context , _ . cloneDeep ( param . schema ) , {
1774
+ resolveFor : PROCESSING_TYPE . VALIDATION
1775
+ } ) ,
1763
1776
{ style, explode } = getParamSerialisationInfo ( param , PARAMETER_SOURCE . REQUEST , components , options ) ,
1764
1777
encodingObj = { [ param . name ] : { style, explode } } ,
1765
1778
metaInfo = {
@@ -1862,7 +1875,9 @@ function checkQueryParams (context, queryParams, transactionPathPrefix, schemaPa
1862
1875
} ;
1863
1876
1864
1877
if ( options . suggestAvailableFixes ) {
1865
- const resolvedSchema = resolveSchema ( context , qp . schema , 0 , PROCESSING_TYPE . VALIDATION ) ;
1878
+ const resolvedSchema = resolveSchema ( context , qp . schema , {
1879
+ resolveFor : PROCESSING_TYPE . VALIDATION
1880
+ } ) ;
1866
1881
1867
1882
mismatchObj . suggestedFix = {
1868
1883
key : qp . name ,
@@ -2000,7 +2015,9 @@ function checkRequestHeaders (context, headers, transactionPathPrefix, schemaPat
2000
2015
} ;
2001
2016
2002
2017
if ( options . suggestAvailableFixes ) {
2003
- const resolvedSchema = resolveSchema ( context , header . schema , 0 , PROCESSING_TYPE . VALIDATION ) ;
2018
+ const resolvedSchema = resolveSchema ( context , header . schema , {
2019
+ resolveFor : PROCESSING_TYPE . VALIDATION
2020
+ } ) ;
2004
2021
2005
2022
mismatchObj . suggestedFix = {
2006
2023
key : header . name ,
@@ -2131,15 +2148,18 @@ function checkResponseHeaders (context, schemaResponse, headers, transactionPath
2131
2148
} ;
2132
2149
2133
2150
if ( options . suggestAvailableFixes ) {
2134
- const resolvedSchema = resolveSchema ( context , header . schema , 0 , PROCESSING_TYPE . VALIDATION ) ;
2151
+ const resolvedSchema = resolveSchema ( context , header . schema , {
2152
+ resolveFor : PROCESSING_TYPE . VALIDATION ,
2153
+ isResponseSchema : true
2154
+ } ) ;
2135
2155
2136
2156
mismatchObj . suggestedFix = {
2137
2157
key : header . name ,
2138
2158
actualValue : null ,
2139
2159
suggestedValue : {
2140
2160
key : header . name ,
2141
2161
value : safeSchemaFaker ( context , resolvedSchema || { } , PROCESSING_TYPE . VALIDATION ,
2142
- PARAMETER_SOURCE . REQUEST , components , SCHEMA_FORMATS . DEFAULT , schemaCache ) ,
2162
+ PARAMETER_SOURCE . RESPONSE , components , SCHEMA_FORMATS . DEFAULT , schemaCache ) ,
2143
2163
description : getParameterDescription ( header )
2144
2164
}
2145
2165
} ;
@@ -2204,8 +2224,9 @@ function checkRequestBody (context, requestBody, transactionPathPrefix, schemaPa
2204
2224
return param . value !== OAS_NOT_SUPPORTED ;
2205
2225
} ) ;
2206
2226
2207
- urlencodedBodySchema = resolveSchema ( context , urlencodedBodySchema ,
2208
- 0 , PROCESSING_TYPE . VALIDATION ) ;
2227
+ urlencodedBodySchema = resolveSchema ( context , urlencodedBodySchema , {
2228
+ resolveFor : PROCESSING_TYPE . VALIDATION
2229
+ } ) ;
2209
2230
2210
2231
resolvedSchemaParams = resolveFormParamSchema ( urlencodedBodySchema , '' , encodingObj ,
2211
2232
filteredUrlEncodedBody , { } , components , options ) ;
@@ -2313,7 +2334,9 @@ function checkRequestBody (context, requestBody, transactionPathPrefix, schemaPa
2313
2334
} ;
2314
2335
2315
2336
if ( options . suggestAvailableFixes ) {
2316
- const resolvedSchema = resolveSchema ( context , uParam . schema , 0 , PROCESSING_TYPE . VALIDATION ) ;
2337
+ const resolvedSchema = resolveSchema ( context , uParam . schema , {
2338
+ resolveFor : PROCESSING_TYPE . VALIDATION
2339
+ } ) ;
2317
2340
2318
2341
mismatchObj . suggestedFix = {
2319
2342
key : uParam . name ,
0 commit comments