Skip to content

Commit d6491d5

Browse files
committed
fix: type defs
1 parent cbbfd70 commit d6491d5

File tree

15 files changed

+94
-366
lines changed

15 files changed

+94
-366
lines changed

toolkit/scripts/generate-api-types.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ async function generateApiTypes() {
3535
httpClientType: 'axios',
3636
typePrefix: 'I',
3737
generateClient: true,
38-
generateResponses: true,
39-
extractRequestParams: true,
40-
extractResponseBody: true,
41-
extractRequestBody: true,
42-
extractResponseHeaders: true,
43-
generateResponseTypes: true,
4438
hooks: {
4539
onPrepareConfig: (currentConfiguration) => {
4640
const config = currentConfiguration.config;

toolkit/src/api/Article.ts

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,7 @@
99
* ---------------------------------------------------------------
1010
*/
1111

12-
import {
13-
checkPasswordData,
14-
createData,
15-
deleteByIdData,
16-
findAllData,
17-
findArticlesByCategoryData,
18-
findArticlesByTagData,
19-
findByIdData,
20-
getArchivesData,
21-
getRecommendArticlesData,
22-
recommendData,
23-
updateByIdData,
24-
updateLikesByIdData,
25-
updateViewsByIdData,
26-
} from '../types/data-contracts';
12+
import { IArticle } from '../types/data-contracts';
2713
import { HttpClient, RequestParams } from './HttpClient';
2814

2915
export class Article<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
@@ -33,12 +19,12 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
3319
* @tags Article
3420
* @name create
3521
* @request POST:/article
36-
* @response `200` `createData` 创建文章
3722
*/
3823
create = (params: RequestParams = {}) =>
39-
this.request<createData, any>({
24+
this.request<IArticle[], any>({
4025
path: `/article`,
4126
method: 'POST',
27+
format: 'json',
4228
...params,
4329
});
4430
/**
@@ -47,10 +33,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
4733
* @tags Article
4834
* @name findAll
4935
* @request GET:/article
50-
* @response `200` `findAllData`
5136
*/
5237
findAll = (params: RequestParams = {}) =>
53-
this.request<findAllData, any>({
38+
this.request<void, any>({
5439
path: `/article`,
5540
method: 'GET',
5641
...params,
@@ -61,10 +46,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
6146
* @tags Article
6247
* @name findArticlesByCategory
6348
* @request GET:/article/category/{id}
64-
* @response `200` `findArticlesByCategoryData`
6549
*/
6650
findArticlesByCategory = (id: string, params: RequestParams = {}) =>
67-
this.request<findArticlesByCategoryData, any>({
51+
this.request<void, any>({
6852
path: `/article/category/${id}`,
6953
method: 'GET',
7054
...params,
@@ -75,10 +59,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
7559
* @tags Article
7660
* @name findArticlesByTag
7761
* @request GET:/article/tag/{id}
78-
* @response `200` `findArticlesByTagData`
7962
*/
8063
findArticlesByTag = (id: string, params: RequestParams = {}) =>
81-
this.request<findArticlesByTagData, any>({
64+
this.request<void, any>({
8265
path: `/article/tag/${id}`,
8366
method: 'GET',
8467
...params,
@@ -89,10 +72,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
8972
* @tags Article
9073
* @name getRecommendArticles
9174
* @request GET:/article/all/recommend
92-
* @response `200` `getRecommendArticlesData`
9375
*/
9476
getRecommendArticles = (params: RequestParams = {}) =>
95-
this.request<getRecommendArticlesData, any>({
77+
this.request<void, any>({
9678
path: `/article/all/recommend`,
9779
method: 'GET',
9880
...params,
@@ -103,10 +85,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
10385
* @tags Article
10486
* @name getArchives
10587
* @request GET:/article/archives
106-
* @response `200` `getArchivesData`
10788
*/
10889
getArchives = (params: RequestParams = {}) =>
109-
this.request<getArchivesData, any>({
90+
this.request<void, any>({
11091
path: `/article/archives`,
11192
method: 'GET',
11293
...params,
@@ -117,10 +98,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
11798
* @tags Article
11899
* @name recommend
119100
* @request GET:/article/recommend
120-
* @response `200` `recommendData`
121101
*/
122102
recommend = (params: RequestParams = {}) =>
123-
this.request<recommendData, any>({
103+
this.request<void, any>({
124104
path: `/article/recommend`,
125105
method: 'GET',
126106
...params,
@@ -131,10 +111,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
131111
* @tags Article
132112
* @name findById
133113
* @request GET:/article/{id}
134-
* @response `200` `findByIdData`
135114
*/
136115
findById = (id: string, params: RequestParams = {}) =>
137-
this.request<findByIdData, any>({
116+
this.request<void, any>({
138117
path: `/article/${id}`,
139118
method: 'GET',
140119
...params,
@@ -145,10 +124,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
145124
* @tags Article
146125
* @name updateById
147126
* @request PATCH:/article/{id}
148-
* @response `200` `updateByIdData`
149127
*/
150128
updateById = (id: string, params: RequestParams = {}) =>
151-
this.request<updateByIdData, any>({
129+
this.request<void, any>({
152130
path: `/article/${id}`,
153131
method: 'PATCH',
154132
...params,
@@ -159,10 +137,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
159137
* @tags Article
160138
* @name deleteById
161139
* @request DELETE:/article/{id}
162-
* @response `200` `deleteByIdData`
163140
*/
164141
deleteById = (id: string, params: RequestParams = {}) =>
165-
this.request<deleteByIdData, any>({
142+
this.request<void, any>({
166143
path: `/article/${id}`,
167144
method: 'DELETE',
168145
...params,
@@ -173,10 +150,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
173150
* @tags Article
174151
* @name checkPassword
175152
* @request POST:/article/{id}/checkPassword
176-
* @response `200` `checkPasswordData`
177153
*/
178154
checkPassword = (id: string, params: RequestParams = {}) =>
179-
this.request<checkPasswordData, any>({
155+
this.request<void, any>({
180156
path: `/article/${id}/checkPassword`,
181157
method: 'POST',
182158
...params,
@@ -187,10 +163,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
187163
* @tags Article
188164
* @name updateViewsById
189165
* @request POST:/article/{id}/views
190-
* @response `200` `updateViewsByIdData`
191166
*/
192167
updateViewsById = (id: string, params: RequestParams = {}) =>
193-
this.request<updateViewsByIdData, any>({
168+
this.request<void, any>({
194169
path: `/article/${id}/views`,
195170
method: 'POST',
196171
...params,
@@ -201,10 +176,9 @@ export class Article<SecurityDataType = unknown> extends HttpClient<SecurityData
201176
* @tags Article
202177
* @name updateLikesById
203178
* @request POST:/article/{id}/likes
204-
* @response `200` `updateLikesByIdData`
205179
*/
206180
updateLikesById = (id: string, params: RequestParams = {}) =>
207-
this.request<updateLikesByIdData, any>({
181+
this.request<void, any>({
208182
path: `/article/${id}/likes`,
209183
method: 'POST',
210184
...params,

toolkit/src/api/Auth.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
* ---------------------------------------------------------------
1010
*/
1111

12-
import {
13-
createBookData,
14-
loginData,
15-
loginWithGithubData,
16-
} from '../types/data-contracts';
1712
import { HttpClient, RequestParams } from './HttpClient';
1813

1914
export class Auth<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
@@ -23,10 +18,9 @@ export class Auth<SecurityDataType = unknown> extends HttpClient<SecurityDataTyp
2318
* @tags Auth
2419
* @name login
2520
* @request POST:/auth/login
26-
* @response `200` `loginData`
2721
*/
2822
login = (params: RequestParams = {}) =>
29-
this.request<loginData, any>({
23+
this.request<void, any>({
3024
path: `/auth/login`,
3125
method: 'POST',
3226
...params,
@@ -37,10 +31,9 @@ export class Auth<SecurityDataType = unknown> extends HttpClient<SecurityDataTyp
3731
* @tags Auth
3832
* @name createBook
3933
* @request POST:/auth/admin
40-
* @response `201` `createBookData`
4134
*/
4235
createBook = (params: RequestParams = {}) =>
43-
this.request<createBookData, any>({
36+
this.request<void, any>({
4437
path: `/auth/admin`,
4538
method: 'POST',
4639
...params,
@@ -51,10 +44,9 @@ export class Auth<SecurityDataType = unknown> extends HttpClient<SecurityDataTyp
5144
* @tags Auth
5245
* @name loginWithGithub
5346
* @request POST:/auth/github
54-
* @response `201` `loginWithGithubData`
5547
*/
5648
loginWithGithub = (params: RequestParams = {}) =>
57-
this.request<loginWithGithubData, any>({
49+
this.request<void, any>({
5850
path: `/auth/github`,
5951
method: 'POST',
6052
...params,

toolkit/src/api/Category.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99
* ---------------------------------------------------------------
1010
*/
1111

12-
import {
13-
createData,
14-
deleteByIdData,
15-
findAllData,
16-
findByIdData,
17-
updateByIdData,
18-
} from '../types/data-contracts';
12+
import { ICategory } from '../types/data-contracts';
1913
import { HttpClient, RequestParams } from './HttpClient';
2014

2115
export class Category<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
@@ -25,12 +19,12 @@ export class Category<SecurityDataType = unknown> extends HttpClient<SecurityDat
2519
* @tags Category
2620
* @name create
2721
* @request POST:/category
28-
* @response `200` `createData` 添加分类
2922
*/
3023
create = (params: RequestParams = {}) =>
31-
this.request<createData, any>({
24+
this.request<ICategory[], any>({
3225
path: `/category`,
3326
method: 'POST',
27+
format: 'json',
3428
...params,
3529
});
3630
/**
@@ -39,10 +33,9 @@ export class Category<SecurityDataType = unknown> extends HttpClient<SecurityDat
3933
* @tags Category
4034
* @name findAll
4135
* @request GET:/category
42-
* @response `200` `findAllData`
4336
*/
4437
findAll = (params: RequestParams = {}) =>
45-
this.request<findAllData, any>({
38+
this.request<void, any>({
4639
path: `/category`,
4740
method: 'GET',
4841
...params,
@@ -53,10 +46,9 @@ export class Category<SecurityDataType = unknown> extends HttpClient<SecurityDat
5346
* @tags Category
5447
* @name findById
5548
* @request GET:/category/{id}
56-
* @response `200` `findByIdData`
5749
*/
5850
findById = (id: string, params: RequestParams = {}) =>
59-
this.request<findByIdData, any>({
51+
this.request<void, any>({
6052
path: `/category/${id}`,
6153
method: 'GET',
6254
...params,
@@ -67,10 +59,9 @@ export class Category<SecurityDataType = unknown> extends HttpClient<SecurityDat
6759
* @tags Category
6860
* @name updateById
6961
* @request PATCH:/category/{id}
70-
* @response `200` `updateByIdData`
7162
*/
7263
updateById = (id: string, params: RequestParams = {}) =>
73-
this.request<updateByIdData, any>({
64+
this.request<void, any>({
7465
path: `/category/${id}`,
7566
method: 'PATCH',
7667
...params,
@@ -81,10 +72,9 @@ export class Category<SecurityDataType = unknown> extends HttpClient<SecurityDat
8172
* @tags Category
8273
* @name deleteById
8374
* @request DELETE:/category/{id}
84-
* @response `200` `deleteByIdData`
8575
*/
8676
deleteById = (id: string, params: RequestParams = {}) =>
87-
this.request<deleteByIdData, any>({
77+
this.request<void, any>({
8878
path: `/category/${id}`,
8979
method: 'DELETE',
9080
...params,

0 commit comments

Comments
 (0)