@@ -1130,7 +1130,8 @@ function resolveFormParamSchema (schema, schemaKey, encodingObj, requestParams,
1130
1130
in : 'query' , // serialization follows same behaviour as query params
1131
1131
description : _ . get ( schema , 'description' , _ . get ( metaInfo , 'description' , '' ) ) ,
1132
1132
pathPrefix : _ . get ( metaInfo , 'pathPrefix' ) ,
1133
- isComposite : _ . get ( metaInfo , 'isComposite' , false )
1133
+ isComposite : _ . get ( metaInfo , 'isComposite' , false ) ,
1134
+ deprecated : _ . get ( schema , 'deprecated' , _ . get ( metaInfo , 'deprecated' ) )
1134
1135
} ;
1135
1136
encodingValue = _ . get ( encodingObj , schemaKey ) ;
1136
1137
@@ -1167,7 +1168,8 @@ function resolveFormParamSchema (schema, schemaKey, encodingObj, requestParams,
1167
1168
in : 'query' , // serialization follows same behaviour as query params
1168
1169
description : _ . get ( propSchema , 'description' ) || _ . get ( metaInfo , 'description' ) || '' ,
1169
1170
required : _ . get ( metaInfo , 'required' ) ,
1170
- isComposite : _ . get ( metaInfo , 'isComposite' , false )
1171
+ isComposite : _ . get ( metaInfo , 'isComposite' , false ) ,
1172
+ deprecated : _ . get ( propSchema , 'deprecated' ) || _ . get ( metaInfo , 'deprecated' )
1171
1173
} ,
1172
1174
parentPropName = resolvedPropName . indexOf ( '[' ) === - 1 ? resolvedPropName :
1173
1175
resolvedPropName . slice ( 0 , resolvedPropName . indexOf ( '[' ) ) ,
@@ -1184,6 +1186,10 @@ function resolveFormParamSchema (schema, schemaKey, encodingObj, requestParams,
1184
1186
resolvedProp . required = true ;
1185
1187
}
1186
1188
1189
+ if ( _ . isUndefined ( metaInfo . required ) && _ . includes ( _ . get ( schema , 'required' ) , propName ) ) {
1190
+ resolvedProp . required = true ;
1191
+ }
1192
+
1187
1193
pSerialisationInfo = getParamSerialisationInfo ( resolvedProp , PARAMETER_SOURCE . REQUEST ,
1188
1194
components , options ) ;
1189
1195
isPropSeparable = _ . includes ( [ 'form' , 'deepObject' ] , pSerialisationInfo . style ) ;
@@ -1217,7 +1223,8 @@ function resolveFormParamSchema (schema, schemaKey, encodingObj, requestParams,
1217
1223
else if ( isPropSeparable && propSchema . type === 'object' && pSerialisationInfo . explode ) {
1218
1224
let localMetaInfo = _ . isEmpty ( metaInfo ) ? ( metaInfo = {
1219
1225
required : resolvedProp . required ,
1220
- description : resolvedProp . description
1226
+ description : resolvedProp . description ,
1227
+ deprecated : _ . get ( resolvedProp , 'deprecated' )
1221
1228
} ) : metaInfo ,
1222
1229
nextSchemaKey = _ . isEmpty ( schemaKey ) ? propName : `${ schemaKey } [${ propName } ]` ;
1223
1230
@@ -1235,7 +1242,8 @@ function resolveFormParamSchema (schema, schemaKey, encodingObj, requestParams,
1235
1242
isResolvedParam : true ,
1236
1243
required : resolvedProp . required ,
1237
1244
description : resolvedProp . description ,
1238
- isComposite : _ . get ( metaInfo , 'isComposite' , false )
1245
+ isComposite : _ . get ( metaInfo , 'isComposite' , false ) ,
1246
+ deprecated : _ . get ( resolvedProp , 'deprecated' ) || _ . get ( metaInfo , 'deprecated' )
1239
1247
} ) ;
1240
1248
} ) ;
1241
1249
}
@@ -1288,7 +1296,8 @@ function resolveFormParamSchema (schema, schemaKey, encodingObj, requestParams,
1288
1296
description : _ . get ( additionalPropSchema , 'description' ) || _ . get ( metaInfo , 'description' ) || '' ,
1289
1297
required : false ,
1290
1298
isResolvedParam : true ,
1291
- isComposite : true
1299
+ isComposite : true ,
1300
+ deprecated : _ . get ( additionalPropSchema , 'deprecated' ) || _ . get ( metaInfo , 'deprecated' )
1292
1301
} ) ;
1293
1302
}
1294
1303
} ) ;
@@ -1729,7 +1738,8 @@ function checkQueryParams (context, queryParams, transactionPathPrefix, schemaPa
1729
1738
let schemaParams = _ . filter ( schemaPath . parameters , ( param ) => { return param . in === 'query' ; } ) ,
1730
1739
requestQueryParams = [ ] ,
1731
1740
resolvedSchemaParams = [ ] ,
1732
- mismatchProperty = 'QUERYPARAM' ;
1741
+ mismatchProperty = 'QUERYPARAM' ,
1742
+ { includeDeprecated } = context . computedOptions ;
1733
1743
1734
1744
if ( options . validationPropertiesToIgnore . includes ( mismatchProperty ) ) {
1735
1745
return callback ( null , [ ] ) ;
@@ -1755,6 +1765,7 @@ function checkQueryParams (context, queryParams, transactionPathPrefix, schemaPa
1755
1765
metaInfo = {
1756
1766
required : _ . get ( param , 'required' ) || false ,
1757
1767
description : _ . get ( param , 'description' ) ,
1768
+ deprecated : _ . get ( param , 'deprecated' ) || false ,
1758
1769
pathPrefix
1759
1770
} ;
1760
1771
@@ -1826,6 +1837,10 @@ function checkQueryParams (context, queryParams, transactionPathPrefix, schemaPa
1826
1837
} ) ;
1827
1838
1828
1839
_ . each ( filteredSchemaParams , ( qp ) => {
1840
+ if ( qp . deprecated && ! includeDeprecated ) {
1841
+ return ;
1842
+ }
1843
+
1829
1844
if ( ! _ . find ( requestQueryParams , ( param ) => {
1830
1845
return param . key === qp . name ;
1831
1846
} ) ) {
@@ -1876,7 +1891,8 @@ function checkRequestHeaders (context, headers, transactionPathPrefix, schemaPat
1876
1891
1877
1892
return ! _ . includes ( IMPLICIT_HEADERS , _ . toLower ( _ . get ( header , 'key' ) ) ) ;
1878
1893
} ) ,
1879
- mismatchProperty = 'HEADER' ;
1894
+ mismatchProperty = 'HEADER' ,
1895
+ { includeDeprecated } = context . computedOptions ;
1880
1896
1881
1897
if ( options . validationPropertiesToIgnore . includes ( mismatchProperty ) ) {
1882
1898
return callback ( null , [ ] ) ;
@@ -1931,7 +1947,8 @@ function checkRequestHeaders (context, headers, transactionPathPrefix, schemaPat
1931
1947
let mismatches = [ ] ,
1932
1948
mismatchObj ,
1933
1949
reqBody = _ . get ( schemaPath , 'requestBody' ) ,
1934
- contentHeaderMismatches = [ ] ;
1950
+ contentHeaderMismatches = [ ] ,
1951
+ filteredHeaders ;
1935
1952
1936
1953
// resolve $ref in request body if present
1937
1954
if ( reqBody ) {
@@ -1943,17 +1960,24 @@ function checkRequestHeaders (context, headers, transactionPathPrefix, schemaPat
1943
1960
schemaPathPrefix + '.requestBody.content' , _ . get ( reqBody , 'content' ) ,
1944
1961
mismatchProperty , options ) ;
1945
1962
}
1946
- _ . each ( _ . filter ( schemaHeaders , ( h ) => {
1963
+
1964
+ filteredHeaders = _ . filter ( schemaHeaders , ( h ) => {
1947
1965
// exclude non-required, non-composite and implicit header from further validation
1948
1966
const isImplicitHeader = _ . includes ( IMPLICIT_HEADERS , _ . toLower ( h . name ) ) ;
1949
1967
1950
1968
if ( VALIDATE_OPTIONAL_PARAMS ) {
1951
1969
return ! h . isComposite && ! isImplicitHeader ;
1952
1970
}
1953
1971
return h . required && ! h . isComposite && ! isImplicitHeader ;
1954
- } ) , ( header ) => {
1972
+ } ) ;
1973
+
1974
+ _ . each ( filteredHeaders , ( header ) => {
1955
1975
if ( ! _ . find ( reqHeaders , ( param ) => { return param . key === header . name ; } ) ) {
1956
1976
1977
+ if ( header . deprecated && ! includeDeprecated ) {
1978
+ return ;
1979
+ }
1980
+
1957
1981
// assign parameter example(s) as schema examples;
1958
1982
assignParameterExamples ( header ) ;
1959
1983
@@ -1998,7 +2022,8 @@ function checkResponseHeaders (context, schemaResponse, headers, transactionPath
1998
2022
1999
2023
return ! _ . includes ( IMPLICIT_HEADERS , _ . toLower ( _ . get ( header , 'key' ) ) ) ;
2000
2024
} ) ,
2001
- mismatchProperty = 'RESPONSE_HEADER' ;
2025
+ mismatchProperty = 'RESPONSE_HEADER' ,
2026
+ { includeDeprecated } = context . computedOptions ;
2002
2027
2003
2028
if ( options . validationPropertiesToIgnore . includes ( mismatchProperty ) ) {
2004
2029
return callback ( null , [ ] ) ;
@@ -2055,23 +2080,28 @@ function checkResponseHeaders (context, schemaResponse, headers, transactionPath
2055
2080
let mismatches = [ ] ,
2056
2081
mismatchObj ,
2057
2082
contentHeaderMismatches = checkContentTypeHeader ( headers , transactionPathPrefix ,
2058
- schemaPathPrefix + '.content' , _ . get ( schemaResponse , 'content' ) , mismatchProperty , options ) ;
2083
+ schemaPathPrefix + '.content' , _ . get ( schemaResponse , 'content' ) , mismatchProperty , options ) ,
2084
+ filteredHeaders = _ . filter ( schemaHeaders , ( h , hName ) => {
2085
+ // exclude empty headers from validation
2086
+ if ( _ . isEmpty ( h ) ) {
2087
+ return false ;
2088
+ }
2089
+ h . name = hName ;
2059
2090
2060
- _ . each ( _ . filter ( schemaHeaders , ( h , hName ) => {
2061
- // exclude empty headers from validation
2062
- if ( _ . isEmpty ( h ) ) {
2063
- return false ;
2064
- }
2065
- h . name = hName ;
2091
+ // exclude non-required, non-composite and implicit header from further validation
2092
+ const isImplicitHeader = _ . includes ( IMPLICIT_HEADERS , _ . toLower ( hName ) ) ;
2066
2093
2067
- // exclude non-required, non-composite and implicit header from further validation
2068
- const isImplicitHeader = _ . includes ( IMPLICIT_HEADERS , _ . toLower ( hName ) ) ;
2094
+ if ( VALIDATE_OPTIONAL_PARAMS ) {
2095
+ return ! h . isComposite && ! isImplicitHeader ;
2096
+ }
2097
+ return h . required && ! h . isComposite && ! isImplicitHeader ;
2098
+ } ) ;
2069
2099
2070
- if ( VALIDATE_OPTIONAL_PARAMS ) {
2071
- return ! h . isComposite && ! isImplicitHeader ;
2100
+ _ . each ( filteredHeaders , ( header ) => {
2101
+ if ( header . deprecated && ! includeDeprecated ) {
2102
+ return ;
2072
2103
}
2073
- return h . required && ! h . isComposite && ! isImplicitHeader ;
2074
- } ) , ( header ) => {
2104
+
2075
2105
if ( ! _ . find ( resHeaders , ( param ) => { return param . key === header . name ; } ) ) {
2076
2106
2077
2107
// assign parameter example(s) as schema examples;
@@ -2112,7 +2142,8 @@ function checkRequestBody (context, requestBody, transactionPathPrefix, schemaPa
2112
2142
// check for body modes
2113
2143
let jsonSchemaBody ,
2114
2144
jsonContentType ,
2115
- mismatchProperty = 'BODY' ;
2145
+ mismatchProperty = 'BODY' ,
2146
+ { includeDeprecated } = context . computedOptions ;
2116
2147
2117
2148
if ( options . validationPropertiesToIgnore . includes ( mismatchProperty ) ) {
2118
2149
return callback ( null , [ ] ) ;
@@ -2247,6 +2278,10 @@ function checkRequestBody (context, requestBody, transactionPathPrefix, schemaPa
2247
2278
} ) ;
2248
2279
2249
2280
_ . each ( filteredSchemaParams , ( uParam ) => {
2281
+ if ( uParam . deprecated && ! includeDeprecated ) {
2282
+ return ;
2283
+ }
2284
+
2250
2285
// report mismatches only for required properties
2251
2286
if ( ! _ . find ( filteredUrlEncodedBody , ( param ) => { return param . key === uParam . name ; } ) ) {
2252
2287
mismatchObj = {
0 commit comments