1
1
import {
2
2
arrayExpression ,
3
+ arrowFunctionExpression ,
3
4
assignmentPattern ,
4
5
blockStatement ,
5
6
callExpression ,
6
- classMethod ,
7
- ClassMethod ,
7
+ ClassProperty ,
8
+ classProperty ,
8
9
Expression ,
9
10
expressionStatement ,
10
11
Identifier ,
@@ -166,7 +167,7 @@ export function generateOperationMethods({
166
167
extendDependenciesAndGetResult ( generateBinaryType ( binaryTypes , operationImportPath ) , dependencyImports ) ;
167
168
168
169
const modelRegisterValidationSchemaImports : Record < string , true > = { } ;
169
- const methods : ClassMethod [ ] = [ ] ;
170
+ const methodProperties : ClassProperty [ ] = [ ] ;
170
171
const validationStatements : Statement [ ] = [ ] ;
171
172
172
173
if ( validateResponse && ! validationContext ) {
@@ -617,9 +618,7 @@ export function generateOperationMethods({
617
618
) ;
618
619
}
619
620
620
- const operationMethod = classMethod (
621
- 'method' ,
622
- identifier ( operationName ) ,
621
+ const operationMethod = arrowFunctionExpression (
623
622
argument . properties . length > 0
624
623
? [
625
624
isAssignableToEmptyObject ( argument . typeAnnotation . typeAnnotation )
@@ -644,11 +643,12 @@ export function generateOperationMethods({
644
643
)
645
644
] )
646
645
) ;
646
+ const operationMethodProperty = classProperty ( identifier ( operationName ) , operationMethod ) ;
647
647
operationMethod . returnType = tsTypeAnnotation (
648
648
tsTypeReference ( identifier ( 'Promise' ) , tsTypeParameterInstantiation ( [ operationReturn . type ] ) )
649
649
) ;
650
650
extendDependencyImports ( dependencyImports , operationReturn . dependencyImports ) ;
651
- methods . push ( attachJsDocComment ( operationMethod , renderJsDoc ( jsdoc , jsDocRenderConfig ) ) ) ;
651
+ methodProperties . push ( attachJsDocComment ( operationMethodProperty , renderJsDoc ( jsdoc , jsDocRenderConfig ) ) ) ;
652
652
}
653
653
}
654
654
if ( Object . keys ( modelRegisterValidationSchemaImports ) . length > 0 && validationContext ) {
@@ -671,7 +671,7 @@ export function generateOperationMethods({
671
671
) ;
672
672
}
673
673
674
- methods . sort ( ( a , b ) => ( a . key as Identifier ) . name . localeCompare ( ( b . key as Identifier ) . name ) ) ;
674
+ methodProperties . sort ( ( a , b ) => ( a . key as Identifier ) . name . localeCompare ( ( b . key as Identifier ) . name ) ) ;
675
675
676
- return { methods, dependencyImports, validationStatements} ;
676
+ return { methods : methodProperties , dependencyImports, validationStatements} ;
677
677
}
0 commit comments