Created
May 22, 2019 12:45
-
-
Save smashercosmo/92de537bef06378db0e3038c2721f092 to your computer and use it in GitHub Desktop.
Generate fake data out of TypeScript types
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
const execa = require('execa') | |
const jsf = require('json-schema-faker') | |
;(async () => { | |
const { stdout } = await execa( | |
'./node_modules/.bin/ts-json-schema-generator', | |
[ | |
'--path', | |
'./organizations.ts', | |
'--type', | |
'OrganizationType', | |
'--expose', | |
'none', | |
'-c', | |
], | |
) | |
const fakeData = await jsf.resolve(JSON.parse(stdout)) | |
console.log(fakeData) | |
})() |
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
export type OrganizationType = { | |
id: string | |
name: string | |
active: boolean | |
created: number | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment