json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

Support command line interface

Open doganulus opened this issue 1 year ago • 1 comments

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?

doganulus avatar Feb 09 '24 13:02 doganulus

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.

jdesrosiers avatar Feb 12 '24 18:02 jdesrosiers