@@ -15,7 +15,15 @@ import ts from 'typescript';
1515import type { ObjectPropertyDefinitions } from './codegen' ;
1616import { generateCreateApiCall , generateEndpointDefinition , generateImportNode , generateTagTypes } from './codegen' ;
1717import { 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' ;
1927import { capitalize , getOperationDefinitions , getV3Doc , removeUndefined , isQuery as testIsQuery } from './utils' ;
2028import { factory } from './utils/factory' ;
2129
@@ -57,6 +65,15 @@ function operationMatches(pattern?: EndpointMatcher) {
5765 } ;
5866}
5967
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+
6077function withQueryComment < T extends ts . Node > ( node : T , def : QueryArgDefinition , hasTrailingNewLine : boolean ) : T {
6178 const comment = def . origin === 'param' ? def . param . description : def . body . description ;
6279 if ( comment ) {
@@ -264,7 +281,7 @@ export async function generateApi(
264281 const parameters = supportDeepObjects ( [
265282 ...apiGen . resolveArray ( pathItem . parameters ) ,
266283 ...apiGen . resolveArray ( operation . parameters ) ,
267- ] ) ;
284+ ] ) . filter ( argumentMatches ( overrides ?. parameterFilter ) ) ;
268285
269286 const allNames = parameters . map ( ( p ) => p . name ) ;
270287 const queryArg : QueryArgDefinitions = { } ;
0 commit comments