UNPKG

yaml-to-json-schema

Version:

Generate json schema from yaml (swagger, openapi, asyncapi)

25 lines (24 loc) 653 B
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const process_1 = require("process"); const path_1 = require("path"); const index_1 = require("./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 = path_1.resolve(process_1.cwd(), file); const schema = await index_1.parse({ input }); console.log(JSON.stringify(schema, null, 2)); } catch (e) { console.log(e); } })();