forked from raydak-labs/configarr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-api.ts
62 lines (55 loc) · 2.21 KB
/
generate-api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { unlinkSync } from "node:fs";
import path from "node:path";
import { generateApi } from "swagger-typescript-api";
const PATH_TO_OUTPUT_DIR = path.resolve(process.cwd(), "./src/__generated__");
const PATH_SONARR_DIR = path.resolve(PATH_TO_OUTPUT_DIR, "sonarr");
const PATH_RADARR_DIR = path.resolve(PATH_TO_OUTPUT_DIR, "radarr");
const PATH_WHISPARR_DIR = path.resolve(PATH_TO_OUTPUT_DIR, "whisparr");
const PATH_READARR_DIR = path.resolve(PATH_TO_OUTPUT_DIR, "readarr");
const main = async () => {
await generateApi({
output: PATH_SONARR_DIR,
url: "https://raw.githubusercontent.com/Sonarr/Sonarr/develop/src/Sonarr.Api.V3/openapi.json",
modular: true,
singleHttpClient: true,
// @ts-ignore little hack to have one single client (we are deleting the weird created file for the http-client)
fileNames: {
httpClient: "../ky-client",
},
});
await generateApi({
output: PATH_RADARR_DIR,
url: "https://raw.githubusercontent.com/Radarr/Radarr/develop/src/Radarr.Api.V3/openapi.json",
modular: true,
singleHttpClient: true,
// @ts-ignore little hack to have one single client (we are deleting the weird created file for the http-client)
fileNames: {
httpClient: "../ky-client",
},
});
await generateApi({
output: PATH_WHISPARR_DIR,
url: "https://raw.githubusercontent.com/Whisparr/Whisparr/develop/src/Whisparr.Api.V3/openapi.json",
modular: true,
singleHttpClient: true,
// @ts-ignore little hack to have one single client (we are deleting the weird created file for the http-client)
fileNames: {
httpClient: "../ky-client",
},
});
await generateApi({
output: PATH_READARR_DIR,
url: "https://raw.githubusercontent.com/Readarr/Readarr/develop/src/Readarr.Api.V1/openapi.json",
modular: true,
singleHttpClient: true,
// @ts-ignore little hack to have one single client (we are deleting the weird created file for the http-client)
fileNames: {
httpClient: "../ky-client",
},
});
unlinkSync(path.resolve(PATH_SONARR_DIR, "..ts"));
unlinkSync(path.resolve(PATH_RADARR_DIR, "..ts"));
unlinkSync(path.resolve(PATH_WHISPARR_DIR, "..ts"));
unlinkSync(path.resolve(PATH_READARR_DIR, "..ts"));
};
main();