@@ -1735,7 +1735,7 @@ function checkQueryParams (context, queryParams, transactionPathPrefix, schemaPa
1735
1735
requestQueryParams = [ ] ,
1736
1736
resolvedSchemaParams = [ ] ,
1737
1737
mismatchProperty = 'QUERYPARAM' ,
1738
- { includeDeprecated } = context . computedOptions ;
1738
+ { includeDeprecated, enableOptionalParameters } = context . computedOptions ;
1739
1739
1740
1740
if ( options . validationPropertiesToIgnore . includes ( mismatchProperty ) ) {
1741
1741
return callback ( null , [ ] ) ;
@@ -1837,6 +1837,11 @@ function checkQueryParams (context, queryParams, transactionPathPrefix, schemaPa
1837
1837
return ;
1838
1838
}
1839
1839
1840
+ // If optional parameters are disabled, do not report them as missing
1841
+ if ( ! enableOptionalParameters && qp . required !== true ) {
1842
+ return ;
1843
+ }
1844
+
1840
1845
if ( ! _ . find ( requestQueryParams , ( param ) => {
1841
1846
return param . key === qp . name ;
1842
1847
} ) ) {
@@ -1888,7 +1893,7 @@ function checkRequestHeaders (context, headers, transactionPathPrefix, schemaPat
1888
1893
return ! _ . includes ( IMPLICIT_HEADERS , _ . toLower ( _ . get ( header , 'key' ) ) ) ;
1889
1894
} ) ,
1890
1895
mismatchProperty = 'HEADER' ,
1891
- { includeDeprecated } = context . computedOptions ;
1896
+ { includeDeprecated, enableOptionalParameters } = context . computedOptions ;
1892
1897
1893
1898
if ( options . validationPropertiesToIgnore . includes ( mismatchProperty ) ) {
1894
1899
return callback ( null , [ ] ) ;
@@ -1974,6 +1979,11 @@ function checkRequestHeaders (context, headers, transactionPathPrefix, schemaPat
1974
1979
return ;
1975
1980
}
1976
1981
1982
+ // If optional parameters are disabled, do not report them as missing
1983
+ if ( ! enableOptionalParameters && header . required !== true ) {
1984
+ return ;
1985
+ }
1986
+
1977
1987
// assign parameter example(s) as schema examples;
1978
1988
assignParameterExamples ( header ) ;
1979
1989
@@ -2019,7 +2029,7 @@ function checkResponseHeaders (context, schemaResponse, headers, transactionPath
2019
2029
return ! _ . includes ( IMPLICIT_HEADERS , _ . toLower ( _ . get ( header , 'key' ) ) ) ;
2020
2030
} ) ,
2021
2031
mismatchProperty = 'RESPONSE_HEADER' ,
2022
- { includeDeprecated } = context . computedOptions ;
2032
+ { includeDeprecated, enableOptionalParameters } = context . computedOptions ;
2023
2033
2024
2034
if ( options . validationPropertiesToIgnore . includes ( mismatchProperty ) ) {
2025
2035
return callback ( null , [ ] ) ;
@@ -2098,6 +2108,11 @@ function checkResponseHeaders (context, schemaResponse, headers, transactionPath
2098
2108
return ;
2099
2109
}
2100
2110
2111
+ // If optional parameters are disabled, do not report them as missing
2112
+ if ( ! enableOptionalParameters && header . required !== true ) {
2113
+ return ;
2114
+ }
2115
+
2101
2116
if ( ! _ . find ( resHeaders , ( param ) => { return param . key === header . name ; } ) ) {
2102
2117
2103
2118
// assign parameter example(s) as schema examples;
@@ -2139,7 +2154,7 @@ function checkRequestBody (context, requestBody, transactionPathPrefix, schemaPa
2139
2154
let jsonSchemaBody ,
2140
2155
jsonContentType ,
2141
2156
mismatchProperty = 'BODY' ,
2142
- { includeDeprecated } = context . computedOptions ;
2157
+ { includeDeprecated, enableOptionalParameters } = context . computedOptions ;
2143
2158
2144
2159
if ( options . validationPropertiesToIgnore . includes ( mismatchProperty ) ) {
2145
2160
return callback ( null , [ ] ) ;
@@ -2278,6 +2293,11 @@ function checkRequestBody (context, requestBody, transactionPathPrefix, schemaPa
2278
2293
return ;
2279
2294
}
2280
2295
2296
+ // If optional parameters are disabled, do not report them as missing
2297
+ if ( ! enableOptionalParameters && uParam . required !== true ) {
2298
+ return ;
2299
+ }
2300
+
2281
2301
// report mismatches only for required properties
2282
2302
if ( ! _ . find ( filteredUrlEncodedBody , ( param ) => { return param . key === uParam . name ; } ) ) {
2283
2303
mismatchObj = {
0 commit comments