@@ -112,11 +112,9 @@ const createOperationHandlers = (
112112 enter ( ) {
113113 currentOperationParams = new Set ( ) ;
114114 } ,
115- leave ( _op : unknown , { report, location } : UserContext ) {
115+ leave ( _operation : unknown , { report, location } : UserContext ) {
116116 if ( ! pathContext . current || ! currentOperationParams ) return ;
117117
118- collectPathParamsFromOperation ( _op , currentOperationParams ) ;
119-
120118 validateRequiredPathParams (
121119 pathContext . current . templateParams ,
122120 currentOperationParams ,
@@ -127,6 +125,8 @@ const createOperationHandlers = (
127125 ) ;
128126 } ,
129127 Parameter ( parameter : Oas2Parameter | Oas3Parameter , { report, location } : UserContext ) {
128+ collectPathParamsFromOperation ( parameter , currentOperationParams ) ;
129+
130130 if ( parameter . in === 'path' && parameter . name && pathContext . current ) {
131131 currentOperationParams . add ( parameter . name ) ;
132132 validatePathParameter (
@@ -150,13 +150,15 @@ const extractTemplateParams = (path: string): Set<string> => {
150150 return new Set ( Array . from ( path . matchAll ( pathRegex ) ) . map ( ( m ) => m [ 1 ] ) ) ;
151151} ;
152152
153- const collectPathParamsFromOperation = ( operation : unknown , targetSet : Set < string > ) : void => {
154- const op = operation as { parameters ?: Array < { in ?: string ; name ?: string } > } ;
155- op ?. parameters ?. forEach ( ( param ) => {
156- if ( param ?. in === 'path' && param ?. name ) {
157- targetSet . add ( param . name ) ;
153+ const collectPathParamsFromOperation = (
154+ parameter : Oas2Parameter | Oas3Parameter ,
155+ targetSet : Set < string >
156+ ) : void => {
157+ if ( parameter && typeof parameter === 'object' && 'in' in parameter && 'name' in parameter ) {
158+ if ( parameter . in === 'path' && parameter . name ) {
159+ targetSet . add ( parameter . name ) ;
158160 }
159- } ) ;
161+ }
160162} ;
161163
162164const validatePathParameter = (
0 commit comments