json-schema-ref-parser-sync

Synchronous API for JSON Schema $Ref Parser

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
json-schema-ref-parser-sync
1.0.06 years ago6 years agoMinified + gzip package size for json-schema-ref-parser-sync in KB

Readme

Synchronous API For JSON Schema $Ref Parser
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 24: Syncronous API.
I hope this will go away some time soon, when JSON Schema $Ref Parser gains a synchronous API of its own.