Skip to content

Commit cf315e9

Browse files
committed
fix: 缺失patch方法
1 parent 027d28f commit cf315e9

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/lib/generate-template.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,27 @@ var ${className} = class extends BaseOpenapiClient {
106106
get(uri, ...rest) {
107107
return this.request(uri, "get", rest[0] || {});
108108
}
109+
109110
post(uri, ...rest) {
110111
return this.request(uri, "post", rest[0] || {});
111112
}
113+
112114
put(uri, ...rest) {
113115
return this.request(uri, "put", rest[0] || {});
114116
}
117+
118+
patch(uri, ...rest) {
119+
return this.request(uri, "patch", rest[0] || {});
120+
}
121+
115122
delete(uri, ...rest) {
116123
return this.request(uri, "delete", rest[0] || {});
117124
}
125+
118126
getContentTypes(uri, method) {
119127
return contentTypes${className}[uri + " " + method] || [void 0, void 0];
120128
}
121-
};
122-
`;
129+
};`;
123130
};
124131

125132
export const generateContentTypeTpl = (className: string, metas: Metas) => {

test/lib/generate-template.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,23 @@ test('完整的类型提示', async () => {
113113
get(uri, ...rest) {
114114
return this.request(uri, "get", rest[0] || {});
115115
}
116+
116117
post(uri, ...rest) {
117118
return this.request(uri, "post", rest[0] || {});
118119
}
120+
119121
put(uri, ...rest) {
120122
return this.request(uri, "put", rest[0] || {});
121123
}
124+
125+
patch(uri, ...rest) {
126+
return this.request(uri, "patch", rest[0] || {});
127+
}
128+
122129
delete(uri, ...rest) {
123130
return this.request(uri, "delete", rest[0] || {});
124131
}
132+
125133
getContentTypes(uri, method) {
126134
return contentTypesOpenapiClient[uri + " " + method] || [void 0, void 0];
127135
}
@@ -350,15 +358,23 @@ describe('类', () => {
350358
get(uri, ...rest) {
351359
return this.request(uri, 'get', rest[0] || {});
352360
}
361+
353362
post(uri, ...rest) {
354363
return this.request(uri, 'post', rest[0] || {});
355364
}
365+
356366
put(uri, ...rest) {
357367
return this.request(uri, 'put', rest[0] || {});
358368
}
369+
370+
patch(uri, ...rest) {
371+
return this.request(uri, 'patch', rest[0] || {});
372+
}
373+
359374
delete(uri, ...rest) {
360375
return this.request(uri, 'delete', rest[0] || {});
361376
}
377+
362378
getContentTypes(uri, method) {
363379
return contentTypesClient[uri + ' ' + method] || [void 0, void 0];
364380
}

0 commit comments

Comments
 (0)