Skip to content

Instantly share code, notes, and snippets.

@smashercosmo
Created May 22, 2019 12:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smashercosmo/92de537bef06378db0e3038c2721f092 to your computer and use it in GitHub Desktop.
Save smashercosmo/92de537bef06378db0e3038c2721f092 to your computer and use it in GitHub Desktop.
Generate fake data out of TypeScript types
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)
})()
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