-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tiny spike to see how far we can get with generating JSON Schema from…
… our TS types
- Loading branch information
1 parent
9c53637
commit d256374
Showing
5 changed files
with
5,310 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env -S node -r @swc-node/register | ||
|
||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
import {createGenerator} from "ts-json-schema-generator"; | ||
|
||
import type {Config} from "ts-json-schema-generator"; | ||
|
||
const config: Config = { | ||
schemaId: "https://khanacademy.org/schema/perseus.json", | ||
tsconfig: path.join(__dirname, "..", "tsconfig.json"), | ||
jsDoc: "extended", | ||
|
||
// type: "PerseusItem", | ||
}; | ||
|
||
const outputPath = path.join(__dirname, "generated/schema.json"); | ||
fs.mkdirSync(path.dirname(outputPath), {recursive: true}); | ||
|
||
const schema = createGenerator(config).createSchema("PerseusItem"); // config.type); | ||
const schemaString = JSON.stringify(schema, null, 2); | ||
fs.writeFile(outputPath, schemaString, (err) => { | ||
if (err) { | ||
throw err; | ||
} | ||
}); |
Oops, something went wrong.