I really can't figure out how to just import a schema that's defined inline. How do I load a simple schema and then execute it using this library without using abolute paths or host it online?
const JsonSchema = require("@hyperjump/json-schema");
const sch = JSON.parse(`{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://somesite.com/schema/base",
"type": "object",
"title": "This is the outer doc",
"properties": {
"version": { "type": "string" },
"info": { "$ref": "/schema/info" }
},
"required": ["version", "info"],
"$defs": {
"info": {
"$id": "/schema/info",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"issuer": { "type": "string" }
},
"required": ["issuer"]
}
}
}`)
const input = {
"version": "test",
"info": { "issuer": "test" },
}
JsonSchema.validate(sch, input).then(console.log).catch(console.error)