-
-
Notifications
You must be signed in to change notification settings - Fork 385
/
Copy pathextended.test.ts
47 lines (38 loc) · 1.18 KB
/
extended.test.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
import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { generateApi } from "../src/index.js";
import { collectAllSchemas } from "./utils.js";
describe("extended", async () => {
let tmpdir: string;
beforeAll(async () => {
tmpdir = await fs.mkdtemp(path.join(os.tmpdir(), "swagger-typescript-api"));
});
afterAll(async () => {
await fs.rm(tmpdir, { recursive: true });
});
const schemas = await collectAllSchemas();
test.each(schemas)("$name", async (schema) => {
await generateApi({
fileName: schema.name,
input: schema.filePath,
output: tmpdir,
silent: true,
extractEnums: true,
extractRequestBody: true,
extractRequestParams: true,
extractResponseBody: true,
extractResponseError: true,
extractResponses: true,
generateClient: true,
generateRouteTypes: true,
sortRoutes: true,
sortTypes: true,
});
const content = await fs.readFile(path.join(tmpdir, `${schema.name}.ts`), {
encoding: "utf8",
});
expect(content).toMatchSnapshot();
});
});