Skip to content

Instantly share code, notes, and snippets.

@iamjochem
Last active October 13, 2017 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamjochem/8fcb056301c4c846773f62022b9831cd to your computer and use it in GitHub Desktop.
Save iamjochem/8fcb056301c4c846773f62022b9831cd to your computer and use it in GitHub Desktop.
[Nodejs] json-schema-ref-parser loading bug ...
{ "oneOf" : [
{ "type" : "null" },
{ "type" : "string" },
{ "type" : "array", "items": { "type" : "string" } }
] }
{
"type" : "object",
"properties" : {
"x" : { "$ref": "./a.json" },
"y" : { "$ref": "./a.json" }
}
}
{
"oneOf" : [
{ "$ref" : "./null.json" },
{ "$ref" : "./b.json" }
]
}
{
"oneOf" : [
{ "$ref" : "./null.json" },
{ "$ref" : "./b.json" }
]
}
const $RefParser = require('json-schema-ref-parser');
const opts = {
resolve : {
node_require : {
order : 1,
canRead : file => true,
read : file => require(file.url),
}
}
};
$RefParser.bundle(__dirname + '/c.json', opts).then(s1 =>
$RefParser.bundle(__dirname + '/d.json', opts).then (s2 => {
console.log('TADA!', s1, s2);
})).catch(e => console.error(e));
const clonedeep = require('lodash.clonedeep');
const $RefParser = require('json-schema-ref-parser');
const opts = {
resolve : {
node_require : {
order : 1,
canRead : file => true,
read : file => clonedeep(require(file.url)),
}
}
};
$RefParser.bundle(__dirname + '/c.json', opts).then(s1 =>
$RefParser.bundle(__dirname + '/d.json', opts).then (s2 => {
console.log('TADA!', s1, s2);
})).catch(e => console.error(e));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment