Skip to content

Commit 3452ad7

Browse files
committed
update examples, fix CI
1 parent 5a33a49 commit 3452ad7

11 files changed

+115379
-32184
lines changed

.eslintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
example/*.ts
21
bin
2+
coverage
33
dist
4+
example/*.ts
45
examples
56
**/generated/*
67
**/expected/*

.eslintrc.cjs

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
/** @type {import('@types/eslint').Linter.BaseConfig} */
12
module.exports = {
23
parser: "@typescript-eslint/parser",
4+
parserOptions: {
5+
project: ["./tsconfig.json"],
6+
},
37
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
48
plugins: ["@typescript-eslint"],
59
};

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"printWidth": 120
3+
}

examples/github-api.ts

+114,771
Large diffs are not rendered by default.

examples/stripe-openapi3.ts renamed to examples/stripe-api.ts

+422-2,405
Large diffs are not rendered by default.

examples/stripe-openapi2.ts

-29,693
This file was deleted.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"lint": "eslint .",
4242
"prepare": "npm run build",
4343
"pregenerate": "npm run build",
44+
"update:examples": "node ./scripts/update-examples.js",
4445
"test": "vitest run",
4546
"test:coverage": "vitest run --coverage",
4647
"version": "npm run build"

prettier.config.cjs

-4
This file was deleted.

scripts/update-examples.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { execSync } from "node:child_process";
2+
import { URL } from "node:url";
3+
4+
const specs = {
5+
"github-api":
6+
"https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.yaml",
7+
"stripe-api": "https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.yaml",
8+
// add more
9+
};
10+
11+
async function generateSchemas() {
12+
await Promise.all(
13+
Object.entries(specs).map(async ([name, url]) => {
14+
await execSync(`node ./bin/cli.js ${url} -o ./examples/${name}.ts`, { cwd: new URL("../", import.meta.url) });
15+
})
16+
);
17+
}
18+
19+
generateSchemas();

0 commit comments

Comments
 (0)