Created
March 20, 2017 19:43
-
-
Save robertlong/3d5f771a992ff9374d64d92c95952674 to your computer and use it in GitHub Desktop.
JSON Schema to Typescript with External References
This file contains hidden or 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
#!/usr/bin/env node | |
const path = require('path'); | |
const fs = require('fs'); | |
const RefParser = require('json-schema-ref-parser'); | |
const Generator = require('json-schema-to-typescript'); | |
const schemaPath = process.argv[2]; | |
const outputPath = process.argv[3]; | |
RefParser.dereference(schemaPath) | |
.then((schema) => { | |
return Generator.compile(schema) | |
}) | |
.then((interface) => { | |
fs.writeFile(outputPath, interface, (err) => { | |
if (err) throw err; | |
console.log(`Success! \nOutput to ${outputPath}`); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment