json-schema
json-schema copied to clipboard
Support command line interface
I like to use the Hyperjump's bundle functionality like this one: https://libraries.io/npm/@skriptfabrik%2Fjson-schema-bundler
Does the library currently support the command line interface?
There isn't a CLI, but it wouldn't be hard to make one. Unfortunately, I don't have to time to work on something like that at the moment. I'd be thrilled if someone wanted to contribute a proper cli wrapper, but here's a quick and dirty example if you something urgently.
import "@hyperjump/json-schema/draft-2020-12";
import { bundle } from "@hyperjump/json-schema/bundle";
const mainSchema = process.argv[2];
const result = await bundle(mainSchema);
console.log(JSON.stringify(result, null, " "));
Just pass the initial schema and it will send the bundled schema to stdout: node bundle-cli.js main.schema.json
. This example works for file-based schemas. If you need to register schemas that use $id
, you'd have to expand on the script.