Last active
October 13, 2017 09:49
-
-
Save iamjochem/8fcb056301c4c846773f62022b9831cd to your computer and use it in GitHub Desktop.
[Nodejs] json-schema-ref-parser loading bug ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "oneOf" : [ | |
{ "type" : "null" }, | |
{ "type" : "string" }, | |
{ "type" : "array", "items": { "type" : "string" } } | |
] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type" : "object", | |
"properties" : { | |
"x" : { "$ref": "./a.json" }, | |
"y" : { "$ref": "./a.json" } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"oneOf" : [ | |
{ "$ref" : "./null.json" }, | |
{ "$ref" : "./b.json" } | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"oneOf" : [ | |
{ "$ref" : "./null.json" }, | |
{ "$ref" : "./b.json" } | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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