1.0.0 • Published 6 years ago

json-schema-ref-parser-sync v1.0.0

Weekly downloads
275
License
Apache-2.0
Repository
github
Last release
6 years ago

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.