-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-api.js
41 lines (37 loc) · 1.15 KB
/
generate-api.js
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
import fs from "fs";
import path from "path";
import { generateApi } from "swagger-typescript-api";
const PATH_TO_OUTPUT_DIR = path.resolve(process.cwd(), "./src/__generated__");
/* NOTE: all fields are optional expect one of `input`, `url`, `spec` */
generateApi({
name: "generated-sonarr-api.ts",
output: PATH_TO_OUTPUT_DIR,
url: "https://raw.githubusercontent.com/Sonarr/Sonarr/develop/src/Sonarr.Api.V3/openapi.json",
httpClientType: "axios",
})
.then(({ files, configuration }) => {
files.forEach(({ content, name }) => {
fs.writeFile(path, content);
});
})
.catch((e) => console.error(e));
generateApi({
name: "generated-radarr-api.ts",
output: PATH_TO_OUTPUT_DIR,
url: "https://raw.githubusercontent.com/Radarr/Radarr/develop/src/Radarr.Api.V3/openapi.json",
httpClientType: "axios",
})
.then(({ files, configuration }) => {
files.forEach(({ content, name }) => {
fs.writeFile(path, content);
});
})
.catch((e) => console.error(e));
// generateTemplates({
// cleanOutput: false,
// output: PATH_TO_OUTPUT_DIR,
// httpClientType: "fetch",
// modular: false,
// silent: false,
// rewrite: false,
// });