Skip to content

Commit 75ea679

Browse files
committed
Fix JSON extension
1 parent 32465ab commit 75ea679

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

scripts/download-schemas.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from "node:fs";
2+
import path from "node:path";
23
import { fileURLToPath } from "node:url";
34
import degit from "degit";
45
import { fetch } from "undici";
@@ -26,7 +27,8 @@ const EXAMPLES_DIR = new URL("../examples/", import.meta.url);
2627
export async function download() {
2728
await Promise.all([
2829
...Object.entries(singleFile).map(async ([k, url]) => {
29-
const dest = new URL(`${k}.yaml`, EXAMPLES_DIR);
30+
const ext = path.extname(url);
31+
const dest = new URL(`${k}${ext}`, EXAMPLES_DIR);
3032
if (fs.existsSync(dest)) {
3133
const { mtime } = fs.statSync(dest);
3234
if (Date.now() - mtime.getTime() < ONE_DAY) return; // only update every 24 hours at most

scripts/update-examples.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { execa } from "execa";
2+
import path from "node:path";
23
import { URL } from "node:url";
34
import { download, singleFile, multiFile } from "./download-schemas.js";
45

@@ -7,7 +8,8 @@ async function generateSchemas() {
78
const cwd = new URL("../", import.meta.url);
89
await Promise.all([
910
...Object.keys(singleFile).map(async (name) => {
10-
await execa("node", ["./bin/cli.js", `./examples/${name}.yaml`, "-o", `./examples/${name}.ts`], { cwd });
11+
const ext = path.extname(singleFile[name as keyof typeof singleFile]);
12+
await execa("node", ["./bin/cli.js", `./examples/${name}${ext}`, "-o", `./examples/${name}.ts`], { cwd });
1113
}),
1214
...Object.entries(multiFile).map(async ([name, meta]) => {
1315
await execa(

test/cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe("CLI", () => {
2020
}, 30000);
2121
test("Octokit GHES 3.6 Diff to API", async () => {
2222
const expected = fs.readFileSync(new URL("./examples/octokit-ghes-3.6-diff-to-api.ts", cwd), "utf8").trim();
23-
const { stdout } = await execa(cmd, ["./examples/octokit-ghes-3.6-diff-to-api.yaml"], { cwd });
23+
const { stdout } = await execa(cmd, ["./examples/octokit-ghes-3.6-diff-to-api.json"], { cwd });
2424
expect(stdout).toBe(expected);
2525
}, 30000);
2626
test("Stripe API", async () => {

test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ export type operations = Record<string, never>;
466466
});
467467
describe("Octokit GHES 3.6 Diff to API", () => {
468468
test("default options", async () => {
469-
const generated = await openapiTS(new URL("./octokit-ghes-3.6-diff-to-api.yaml", EXAMPLES_DIR));
469+
const generated = await openapiTS(new URL("./octokit-ghes-3.6-diff-to-api.json", EXAMPLES_DIR));
470470
expect(generated).toBe(fs.readFileSync(new URL("./octokit-ghes-3.6-diff-to-api.ts", EXAMPLES_DIR), "utf8"));
471471
}, 30000);
472472
});

0 commit comments

Comments
 (0)