Skip to content

Commit f1977eb

Browse files
committed
feat(api-client): void return type for methods with empty schema
1 parent d14ef9d commit f1977eb

File tree

10 files changed

+42
-43
lines changed

10 files changed

+42
-43
lines changed

src/helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Reference } from 'swagger-schema-official';
22
import { FileInfix } from './types';
33

4-
export const BASIC_TS_TYPE_REGEX = /\b(?:string|number|integer|boolean)\b/;
5-
const BUILD_IN_TS_TYPE_REGEX = /^(?:string|number|integer|boolean|null|undefined|any|Object|Date|File|Blob)\b/i;
4+
export const BASIC_TS_TYPE_REGEX = /\b(?:string|number|integer|boolean|void)\b/;
5+
const BUILD_IN_TS_TYPE_REGEX = /^(?:string|number|integer|boolean|null|undefined|any|void|Object|Date|File|Blob)\b/i;
66

77
export function toCamelCase(text: string = '', lowerFirst: boolean = true): string {
88
text = removeDuplicateWords(text);

src/parser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ function determineResponseType(response: Response): {
332332
const {schema} = response;
333333

334334
if (schema == null) {
335-
logWarn('200 or 201 response schema not specified; `any` will be used');
336-
return {name: 'any', type: 'any'};
335+
return {name: 'void', type: 'void'};
337336
}
338337

339338
const nullable = (schema as Schema & { 'x-nullable'?: boolean })['x-nullable'] || false;

tests/custom/api/api-client.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface APIClientInterface {
3434
id: string,
3535
},
3636
requestHttpOptions?: HttpOptions
37-
): Observable<any>;
37+
): Observable<void>;
3838

3939
getCustomers(
4040
requestHttpOptions?: HttpOptions

tests/custom/api/api-client.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ export class APIClient implements APIClientInterface {
106106
id: string,
107107
},
108108
requestHttpOptions?: HttpOptions
109-
): Observable<any> {
109+
): Observable<void> {
110110
const path = `/pets/${args.id}`;
111111
const options: APIHttpOptions = {
112112
...this.options,
113113
...requestHttpOptions,
114114
};
115115

116-
return this.sendRequest<any>('DELETE', path, options);
116+
return this.sendRequest<void>('DELETE', path, options);
117117
}
118118

119119
getCustomers(

tests/esquare/api/api-client.interface.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export interface APIClientInterface {
6666
structureId: number, // structure id to delete
6767
},
6868
requestHttpOptions?: HttpOptions
69-
): Observable<any>;
69+
): Observable<void>;
7070

7171
/**
7272
* [Screenshot from design](http://prntscr.com/hy4z8d)
@@ -231,7 +231,7 @@ export interface APIClientInterface {
231231
id: number, // Id of current import
232232
},
233233
requestHttpOptions?: HttpOptions
234-
): Observable<any>;
234+
): Observable<void>;
235235

236236
/**
237237
* [Screenshot from design](http://prntscr.com/hy5bi6)
@@ -244,7 +244,7 @@ export interface APIClientInterface {
244244
file: File, // file to upload
245245
},
246246
requestHttpOptions?: HttpOptions
247-
): Observable<any>;
247+
): Observable<void>;
248248

249249
/**
250250
* [Screenshot from design](http://prntscr.com/i4052r)
@@ -334,7 +334,7 @@ export interface APIClientInterface {
334334
id: number,
335335
},
336336
requestHttpOptions?: HttpOptions
337-
): Observable<any>;
337+
): Observable<void>;
338338

339339
/**
340340
* [Screenshot from design](http://prntscr.com/i93q0s)
@@ -379,7 +379,7 @@ export interface APIClientInterface {
379379
id: number,
380380
},
381381
requestHttpOptions?: HttpOptions
382-
): Observable<any>;
382+
): Observable<void>;
383383

384384
/**
385385
* [Screenshot from design](http://prntscr.com/iba7xr)
@@ -394,7 +394,7 @@ export interface APIClientInterface {
394394
body?: any,
395395
},
396396
requestHttpOptions?: HttpOptions
397-
): Observable<any>;
397+
): Observable<void>;
398398

399399
/**
400400
* [Screenshot from design](http://prntscr.com/iba8tq)
@@ -447,14 +447,14 @@ export interface APIClientInterface {
447447
id: number,
448448
},
449449
requestHttpOptions?: HttpOptions
450-
): Observable<any>;
450+
): Observable<void>;
451451

452452
disableNotification(
453453
args: {
454454
id: number,
455455
},
456456
requestHttpOptions?: HttpOptions
457-
): Observable<any>;
457+
): Observable<void>;
458458

459459
getNotification(
460460
args: {
@@ -469,7 +469,7 @@ export interface APIClientInterface {
469469
body?: models.NotificationEditable,
470470
},
471471
requestHttpOptions?: HttpOptions
472-
): Observable<any>;
472+
): Observable<void>;
473473

474474
createNotification(
475475
args: {

tests/esquare/api/api-client.service.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,14 @@ export class APIClient implements APIClientInterface {
174174
structureId: number, // structure id to delete
175175
},
176176
requestHttpOptions?: HttpOptions
177-
): Observable<any> {
177+
): Observable<void> {
178178
const path = `/structure/${args.structureId}`;
179179
const options: APIHttpOptions = {
180180
...this.options,
181181
...requestHttpOptions,
182182
};
183183

184-
return this.sendRequest<any>('DELETE', path, options);
184+
return this.sendRequest<void>('DELETE', path, options);
185185
}
186186

187187
/**
@@ -484,14 +484,14 @@ export class APIClient implements APIClientInterface {
484484
id: number, // Id of current import
485485
},
486486
requestHttpOptions?: HttpOptions
487-
): Observable<any> {
487+
): Observable<void> {
488488
const path = `/report/wizard/${args.id}/cancelImport`;
489489
const options: APIHttpOptions = {
490490
...this.options,
491491
...requestHttpOptions,
492492
};
493493

494-
return this.sendRequest<any>('POST', path, options);
494+
return this.sendRequest<void>('POST', path, options);
495495
}
496496

497497
/**
@@ -505,14 +505,14 @@ export class APIClient implements APIClientInterface {
505505
file: File, // file to upload
506506
},
507507
requestHttpOptions?: HttpOptions
508-
): Observable<any> {
508+
): Observable<void> {
509509
const path = `/report/wizard/${args.id}/override`;
510510
const options: APIHttpOptions = {
511511
...this.options,
512512
...requestHttpOptions,
513513
};
514514

515-
return this.sendRequest<any>('POST', path, options, JSON.stringify(args.description), JSON.stringify(args.file));
515+
return this.sendRequest<void>('POST', path, options, JSON.stringify(args.description), JSON.stringify(args.file));
516516
}
517517

518518
/**
@@ -730,14 +730,14 @@ export class APIClient implements APIClientInterface {
730730
id: number,
731731
},
732732
requestHttpOptions?: HttpOptions
733-
): Observable<any> {
733+
): Observable<void> {
734734
const path = `/users/${args.id}`;
735735
const options: APIHttpOptions = {
736736
...this.options,
737737
...requestHttpOptions,
738738
};
739739

740-
return this.sendRequest<any>('DELETE', path, options);
740+
return this.sendRequest<void>('DELETE', path, options);
741741
}
742742

743743
/**
@@ -823,14 +823,14 @@ export class APIClient implements APIClientInterface {
823823
id: number,
824824
},
825825
requestHttpOptions?: HttpOptions
826-
): Observable<any> {
826+
): Observable<void> {
827827
const path = `/users/roles/${args.id}`;
828828
const options: APIHttpOptions = {
829829
...this.options,
830830
...requestHttpOptions,
831831
};
832832

833-
return this.sendRequest<any>('DELETE', path, options);
833+
return this.sendRequest<void>('DELETE', path, options);
834834
}
835835

836836
/**
@@ -854,14 +854,14 @@ export class APIClient implements APIClientInterface {
854854
body?: any,
855855
},
856856
requestHttpOptions?: HttpOptions
857-
): Observable<any> {
857+
): Observable<void> {
858858
const path = `/notifications/markAsViewed`;
859859
const options: APIHttpOptions = {
860860
...this.options,
861861
...requestHttpOptions,
862862
};
863863

864-
return this.sendRequest<any>('PUT', path, options, JSON.stringify(args.body));
864+
return this.sendRequest<void>('PUT', path, options, JSON.stringify(args.body));
865865
}
866866

867867
/**
@@ -971,29 +971,29 @@ export class APIClient implements APIClientInterface {
971971
id: number,
972972
},
973973
requestHttpOptions?: HttpOptions
974-
): Observable<any> {
974+
): Observable<void> {
975975
const path = `/notifications/enable/${args.id}`;
976976
const options: APIHttpOptions = {
977977
...this.options,
978978
...requestHttpOptions,
979979
};
980980

981-
return this.sendRequest<any>('PUT', path, options);
981+
return this.sendRequest<void>('PUT', path, options);
982982
}
983983

984984
disableNotification(
985985
args: {
986986
id: number,
987987
},
988988
requestHttpOptions?: HttpOptions
989-
): Observable<any> {
989+
): Observable<void> {
990990
const path = `/notifications/disable/${args.id}`;
991991
const options: APIHttpOptions = {
992992
...this.options,
993993
...requestHttpOptions,
994994
};
995995

996-
return this.sendRequest<any>('PUT', path, options);
996+
return this.sendRequest<void>('PUT', path, options);
997997
}
998998

999999
getNotification(
@@ -1017,14 +1017,14 @@ export class APIClient implements APIClientInterface {
10171017
body?: models.NotificationEditable,
10181018
},
10191019
requestHttpOptions?: HttpOptions
1020-
): Observable<any> {
1020+
): Observable<void> {
10211021
const path = `/notifications/${args.id}`;
10221022
const options: APIHttpOptions = {
10231023
...this.options,
10241024
...requestHttpOptions,
10251025
};
10261026

1027-
return this.sendRequest<any>('PUT', path, options, JSON.stringify(args.body));
1027+
return this.sendRequest<void>('PUT', path, options, JSON.stringify(args.body));
10281028
}
10291029

10301030
createNotification(

tests/github/api/services/markdown/markdown-api-client.interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface MarkdownAPIClientInterface {
2020
body: models.Markdown,
2121
},
2222
requestHttpOptions?: HttpOptions
23-
): Observable<any>;
23+
): Observable<void>;
2424

2525
/**
2626
* Render a Markdown document in raw mode
@@ -35,6 +35,6 @@ export interface MarkdownAPIClientInterface {
3535
xGitHubRequestId?: number,
3636
},
3737
requestHttpOptions?: HttpOptions
38-
): Observable<any>;
38+
): Observable<void>;
3939

4040
}

tests/github/api/services/markdown/markdown-api-client.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class MarkdownAPIClient implements MarkdownAPIClientInterface {
5656
body: models.Markdown,
5757
},
5858
requestHttpOptions?: HttpOptions
59-
): Observable<any> {
59+
): Observable<void> {
6060
const path = `/markdown`;
6161
const options: APIHttpOptions = {
6262
...this.options,
@@ -81,7 +81,7 @@ export class MarkdownAPIClient implements MarkdownAPIClientInterface {
8181
if ('xGitHubRequestId' in args) {
8282
options.headers = options.headers.set('X-GitHub-Request-Id', String(args.xGitHubRequestId));
8383
}
84-
return this.sendRequest<any>('POST', path, options, JSON.stringify(args.body));
84+
return this.sendRequest<void>('POST', path, options, JSON.stringify(args.body));
8585
}
8686

8787
/**
@@ -97,7 +97,7 @@ export class MarkdownAPIClient implements MarkdownAPIClientInterface {
9797
xGitHubRequestId?: number,
9898
},
9999
requestHttpOptions?: HttpOptions
100-
): Observable<any> {
100+
): Observable<void> {
101101
const path = `/markdown/raw`;
102102
const options: APIHttpOptions = {
103103
...this.options,
@@ -122,7 +122,7 @@ export class MarkdownAPIClient implements MarkdownAPIClientInterface {
122122
if ('xGitHubRequestId' in args) {
123123
options.headers = options.headers.set('X-GitHub-Request-Id', String(args.xGitHubRequestId));
124124
}
125-
return this.sendRequest<any>('POST', path, options);
125+
return this.sendRequest<void>('POST', path, options);
126126
}
127127

128128
private sendRequest<T>(method: string, path: string, options: HttpOptions, body?: any): Observable<T> {

tests/github/api/services/repos/repos-api-client.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ export interface ReposAPIClientInterface {
560560
body: models.DeploymentStatusesCreate,
561561
},
562562
requestHttpOptions?: HttpOptions
563-
): Observable<any>;
563+
): Observable<void>;
564564

565565
/**
566566
* Deprecated. List downloads for a repository.

tests/github/api/services/repos/repos-api-client.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ export class ReposAPIClient implements ReposAPIClientInterface {
13481348
body: models.DeploymentStatusesCreate,
13491349
},
13501350
requestHttpOptions?: HttpOptions
1351-
): Observable<any> {
1351+
): Observable<void> {
13521352
const path = `/repos/${args.owner}/${args.repo}/deployments/${args.id}/statuses`;
13531353
const options: APIHttpOptions = {
13541354
...this.options,
@@ -1373,7 +1373,7 @@ export class ReposAPIClient implements ReposAPIClientInterface {
13731373
if ('xGitHubRequestId' in args) {
13741374
options.headers = options.headers.set('X-GitHub-Request-Id', String(args.xGitHubRequestId));
13751375
}
1376-
return this.sendRequest<any>('POST', path, options, JSON.stringify(args.body));
1376+
return this.sendRequest<void>('POST', path, options, JSON.stringify(args.body));
13771377
}
13781378

13791379
/**

0 commit comments

Comments
 (0)