File tree Expand file tree Collapse file tree 4 files changed +61
-2
lines changed
Expand file tree Collapse file tree 4 files changed +61
-2
lines changed Original file line number Diff line number Diff line change @@ -127,8 +127,8 @@ openapi本地或者远程文件,支持格式:`yaml | json`
127127
128128类的生成方式。
129129
130- - ` rest ` ,仅生成 ** get|post|put|patch|delete** 几个方法,uri作为第一个参数传入
131- - ` rpc ` ,把 method+uri 拼接成一个新方法。
130+ - ` rest ` ,仅生成 ** get|post|put|patch|delete** 几个方法,uri作为第一个参数传入。参考: [ rest-mode.js ] ( ./openapi/rest-mode.js )
131+ - ` rpc ` ,把 method+uri 拼接成一个新方法。参考: [ rpc-mode.js ] ( ./openapi/rpc-mode.js )
132132
133133``` typescript
134134const client = new OpenapiClient ();
Original file line number Diff line number Diff line change 1+ ! * .js
Original file line number Diff line number Diff line change 1+ var OpenapiClient = class extends BaseOpenapiClient {
2+ get ( uri , opts ) {
3+ return this . request ( uri , 'get' , opts ) ;
4+ }
5+
6+ post ( uri , opts ) {
7+ return this . request ( uri , 'get' , opts ) ;
8+ }
9+
10+ put ( uri , opts ) {
11+ return this . request ( uri , 'get' , opts ) ;
12+ }
13+
14+ delete ( uri , opts ) {
15+ return this . request ( uri , 'get' , opts ) ;
16+ }
17+
18+ pickContentTypes ( uri , method ) {
19+ return contentTypesOpenapiClient [ method + ' ' + uri ] || [ void 0 , void 0 ] ;
20+ }
21+ } ;
22+
23+ const contentTypesOpenapiClient = {
24+ 'put /users/avatar' : [ 'multipart/form-data' , void 0 ] ,
25+ } ;
Original file line number Diff line number Diff line change 1+ var OpenapiClient = class extends BaseOpenapiClient {
2+ user = {
3+ getUsers : ( opts ) => {
4+ return this . request ( '/users' , 'get' , opts ) ;
5+ } ,
6+ getUsersById : ( opts ) => {
7+ return this . request ( '/users/{id}' , 'get' , opts ) ;
8+ } ,
9+ postUsers : ( opts ) => {
10+ return this . request ( '/users' , 'post' , opts ) ;
11+ } ,
12+ postUsersV1 : ( opts ) => {
13+ return this . request ( '/users/v1' , 'post' , opts ) ;
14+ } ,
15+ putUsersById : ( opts ) => {
16+ return this . request ( '/users/{id}' , 'put' , opts ) ;
17+ } ,
18+ putUsersAvatar : ( opts ) => {
19+ return this . request ( '/users/avatar' , 'put' , opts ) ;
20+ } ,
21+ deleteUsersById : ( opts ) => {
22+ return this . request ( '/users/{id}' , 'delete' , opts ) ;
23+ } ,
24+ } ;
25+
26+ pickContentTypes ( uri , method ) {
27+ return contentTypesOpenapiClient [ method + ' ' + uri ] || [ void 0 , void 0 ] ;
28+ }
29+ } ;
30+
31+ const contentTypesOpenapiClient = {
32+ 'put /users/avatar' : [ 'multipart/form-data' , void 0 ] ,
33+ } ;
You can’t perform that action at this time.
0 commit comments