Skip to content

Commit c6bf3ae

Browse files
committed
fix: rpc-group模式下方法丢失context
1 parent 500cf10 commit c6bf3ae

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/lib/generate-template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class ${className}<T extends object = object> extends BaseOpenapiClient<T
145145
const optional =
146146
meta.query.optional && meta.params.optional && meta.body.optional;
147147
148-
return `${generateComments(meta)}${camelCase(meta.key)}(opts${optional ? '?' : ''}: ${className}_${method}_paths['${meta.uri}']['request'] & BaseOpenapiClient.UserInputOpts<T>): Promise<${className}_${method}_paths['${meta.uri}']['response']> {
148+
return `${generateComments(meta)}${camelCase(meta.key)}: (opts${optional ? '?' : ''}: ${className}_${method}_paths['${meta.uri}']['request'] & BaseOpenapiClient.UserInputOpts<T>): Promise<${className}_${method}_paths['${meta.uri}']['response']> => {
149149
return this.request('${meta.uri}', '${method}', opts);
150150
}`;
151151
});

test/lib/generate-template.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,19 @@ test('完整的类型提示', async () => {
129129
* @uri /users
130130
* @method GET
131131
*/
132-
getUsers(
132+
getUsers: (
133133
opts: OpenapiClient_get_paths["/users"]["request"] & BaseOpenapiClient.UserInputOpts<T>,
134-
): Promise<OpenapiClient_get_paths["/users"]["response"]> {
134+
): Promise<OpenapiClient_get_paths["/users"]["response"]> => {
135135
return this.request("/users", "get", opts);
136136
},
137137
138138
/**
139139
* @uri /users/{id}
140140
* @method GET
141141
*/
142-
getUsersById(
142+
getUsersById: (
143143
opts?: OpenapiClient_get_paths["/users/{id}"]["request"] & BaseOpenapiClient.UserInputOpts<T>,
144-
): Promise<OpenapiClient_get_paths["/users/{id}"]["response"]> {
144+
): Promise<OpenapiClient_get_paths["/users/{id}"]["response"]> => {
145145
return this.request("/users/{id}", "get", opts);
146146
},
147147
};
@@ -494,9 +494,9 @@ describe('类', () => {
494494
* @uri /
495495
* @method GET
496496
*/
497-
getUsers(
497+
getUsers: (
498498
opts?: Client_get_paths['/']['request'] & BaseOpenapiClient.UserInputOpts<T>,
499-
): Promise<Client_get_paths['/']['response']> {
499+
): Promise<Client_get_paths['/']['response']> => {
500500
return this.request('/', 'get', opts);
501501
},
502502
@@ -505,9 +505,9 @@ describe('类', () => {
505505
* @uri /
506506
* @method PATCH
507507
*/
508-
patchUsers(
508+
patchUsers: (
509509
opts?: Client_patch_paths['/']['request'] & BaseOpenapiClient.UserInputOpts<T>,
510-
): Promise<Client_patch_paths['/']['response']> {
510+
): Promise<Client_patch_paths['/']['response']> => {
511511
return this.request('/', 'patch', opts);
512512
},
513513
};
@@ -516,9 +516,9 @@ describe('类', () => {
516516
* @uri /
517517
* @method GET
518518
*/
519-
getUsers(
519+
getUsers: (
520520
opts?: Client_get_paths['/']['request'] & BaseOpenapiClient.UserInputOpts<T>,
521-
): Promise<Client_get_paths['/']['response']> {
521+
): Promise<Client_get_paths['/']['response']> => {
522522
return this.request('/', 'get', opts);
523523
},
524524
};

0 commit comments

Comments
 (0)