yaml-to-json-schema
Version:
Generate json schema from yaml (swagger, openapi, asyncapi)
31 lines (21 loc) • 518 B
text/typescript
import { cwd } from 'process'
import { resolve } from 'path'
import { parse } from './index'
const args = process.argv.splice(2)
;(async () => {
const file = args[0] || ''
if (!file) {
console.log(`
USAGE: yaml-to-json-schema input.yaml
`)
return process.exit()
}
try {
const input: string = resolve(cwd(), file)
const schema = await parse({ input })
console.log(JSON.stringify(schema, null, 2))
} catch (e: unknown) {
console.log(e)
}
})()