1
+ import { EOL } from "os" ;
1
2
import ts from "typescript" ;
2
3
3
4
import type { TsGenerator } from "../../../api" ;
4
5
import type { CodeGenerator } from "../../../types" ;
5
6
import type { Option } from "../../_shared/types" ;
6
- import * as Method from "./Method" ;
7
- import * as ReturnStatement from "./ReturnStatement" ;
8
- export { Method } ;
7
+ import * as ArrowFunction from "./ArrowFunction" ;
9
8
10
9
export const create = ( factory : TsGenerator . Factory . Type , list : CodeGenerator . Params [ ] , option : Option ) : ts . VariableStatement => {
11
- const variableStatements = list . map ( params => {
12
- return Method . create ( factory , params , option ) ;
10
+ const properties = list . map ( params => {
11
+ return factory . PropertyAssignment . create ( {
12
+ name : params . convertedParams . functionName ,
13
+ initializer : ArrowFunction . create ( factory , params , option ) ,
14
+ comment : option . additionalMethodComment
15
+ ? [ params . operationParams . comment , `operationId: ${ params . operationId } ` , `Request URI: ${ params . operationParams . requestUri } ` ]
16
+ . filter ( t => ! ! t )
17
+ . join ( EOL )
18
+ : params . operationParams . comment ,
19
+ } ) ;
20
+ } ) ;
21
+
22
+ const returnValue = factory . ReturnStatement . create ( {
23
+ expression : factory . ObjectLiteralExpression . create ( {
24
+ properties,
25
+ multiLine : true ,
26
+ } ) ,
13
27
} ) ;
14
28
15
29
const arrowFunction = factory . ArrowFunction . create ( {
@@ -36,7 +50,7 @@ export const create = (factory: TsGenerator.Factory.Type, list: CodeGenerator.Pa
36
50
} ) ,
37
51
] ,
38
52
body : factory . Block . create ( {
39
- statements : [ ... variableStatements , ReturnStatement . create ( factory , list ) ] ,
53
+ statements : [ returnValue ] ,
40
54
multiLine : true ,
41
55
} ) ,
42
56
} ) ;
0 commit comments