How to resolve a JsonSchema and move a sub-schema up to the root?
I wrote a schema in JavaScript because its easier, which I can simply run to turn it into JSON. That part is all fine, but now I want to extract a sub-schema/definition because the application I want to use it with won't let me specify a JSON path for the sub-schema I'm interested. So I tried writing a little script to pull it out: #!/usr/bin/env node import Ajv from 'ajv'; import Path from 'path'; const ajv = new Ajv({ $data: true, }); ajv.addSchema(require(Path.resolve(process.argv[2])).default,'x'); const schema = ajv.getSchema(`x#/${process.argv[3]}`).schema; console.log(JSON.stringify(sch
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.