Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function generate(inPath) {
// Best description of how to use the API was found at
// https://blog.quicktype.io/customizing-quicktype/
const inputData = new InputData();
const content = fs.readFileSync(inPath, 'utf-8');
const source = { name: 'Schema', schema: appendDeprecatedDescription(content) };
await inputData.addSource('schema', source, () => {
return new JSONSchemaInput(new FetchingJSONSchemaStore(inPath));
});
const lang = new TypeScriptTargetLanguage();
const { lines } = await quicktype({
lang,
inputData,
alphabetizeProperties: true,
rendererOptions: {
'just-types': 'true',
'explicit-unions': 'true',
'acronym-style': 'camel',
},
});
return header + lines.join('\n') + footer;
}