BigstickCarpet's JSON Schema $Ref Parser is very useful, but at present has no synchronous API -- despite multiple requests for one.
This tiny package uses a hideous hack to present a simple synchronous API to $Ref Parser's dereference
method:
const $SyncRefParser = require('json-schema-ref-parser-sync');
expandedSchema = $SyncRefParser.dereference(schema, options);
$SyncRefParser.dereference
expands the provided JSON Schema's $ref
references, infuenced by the option
if they are provided, and returns the expanded version of the schema. If an error occurs, it throws an Error
object.
This code, such as it is, was inspired by a comment by willfarrell on JSON Schema $Ref Parser's as-yet unresolved issue 14: Syncronous API.
I hope this will go away some time soon, when JSON Schema $Ref Parser gains a synchronous API of its own.