@@ -15,7 +15,15 @@ import ts from 'typescript';
15
15
import type { ObjectPropertyDefinitions } from './codegen' ;
16
16
import { generateCreateApiCall , generateEndpointDefinition , generateImportNode , generateTagTypes } from './codegen' ;
17
17
import { generateReactHooks } from './generators/react-hooks' ;
18
- import type { EndpointMatcher , EndpointOverrides , GenerationOptions , OperationDefinition , TextMatcher } from './types' ;
18
+ import type {
19
+ EndpointMatcher ,
20
+ EndpointOverrides ,
21
+ GenerationOptions ,
22
+ OperationDefinition ,
23
+ ParameterDefinition ,
24
+ ParameterMatcher ,
25
+ TextMatcher ,
26
+ } from './types' ;
19
27
import { capitalize , getOperationDefinitions , getV3Doc , removeUndefined , isQuery as testIsQuery } from './utils' ;
20
28
import { factory } from './utils/factory' ;
21
29
@@ -57,6 +65,15 @@ function operationMatches(pattern?: EndpointMatcher) {
57
65
} ;
58
66
}
59
67
68
+ function argumentMatches ( pattern ?: ParameterMatcher ) {
69
+ const checkMatch = typeof pattern === 'function' ? pattern : patternMatches ( pattern ) ;
70
+ return function matcher ( argumentDefinition : ParameterDefinition ) {
71
+ if ( ! pattern || argumentDefinition . in === 'path' ) return true ;
72
+ const argumentName = argumentDefinition . name ;
73
+ return checkMatch ( argumentName , argumentDefinition ) ;
74
+ } ;
75
+ }
76
+
60
77
function withQueryComment < T extends ts . Node > ( node : T , def : QueryArgDefinition , hasTrailingNewLine : boolean ) : T {
61
78
const comment = def . origin === 'param' ? def . param . description : def . body . description ;
62
79
if ( comment ) {
@@ -264,7 +281,7 @@ export async function generateApi(
264
281
const parameters = supportDeepObjects ( [
265
282
...apiGen . resolveArray ( pathItem . parameters ) ,
266
283
...apiGen . resolveArray ( operation . parameters ) ,
267
- ] ) ;
284
+ ] ) . filter ( argumentMatches ( overrides ?. parameterFilter ) ) ;
268
285
269
286
const allNames = parameters . map ( ( p ) => p . name ) ;
270
287
const queryArg : QueryArgDefinitions = { } ;
0 commit comments