* feat: use string union instead of enum * chore: remove IInterface naming * fix readme * fix quote consistency
15 lines
479 B
JavaScript
15 lines
479 B
JavaScript
import { compile, compileFromFile } from 'json-schema-to-typescript'
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
const typeSchemaContents = fs.readFileSync(path.join(process.cwd(), 'spec.json'), 'utf8');
|
|
const typeSchema = JSON.parse(typeSchemaContents.toString());
|
|
|
|
compile(typeSchema, 'MySchema', {
|
|
additionalProperties: false,
|
|
enableConstEnums: false,
|
|
unreachableDefinitions: true,
|
|
unknownAny: true,
|
|
})
|
|
.then(ts => fs.writeFileSync('src/types.ts', ts))
|