1+ import { EOL } from "os" ;
12import ts from "typescript" ;
23
34import type { TsGenerator } from "../../../api" ;
45import type { CodeGenerator } from "../../../types" ;
56import 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" ;
98
109export 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+ } ) ,
1327 } ) ;
1428
1529 const arrowFunction = factory . ArrowFunction . create ( {
@@ -36,7 +50,7 @@ export const create = (factory: TsGenerator.Factory.Type, list: CodeGenerator.Pa
3650 } ) ,
3751 ] ,
3852 body : factory . Block . create ( {
39- statements : [ ... variableStatements , ReturnStatement . create ( factory , list ) ] ,
53+ statements : [ returnValue ] ,
4054 multiLine : true ,
4155 } ) ,
4256 } ) ;
0 commit comments