json-schema-ref-parser-sync

1.0.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i json-schema-ref-parser-sync

Weekly Downloads

187

Version

1.0.0

License

Apache-2.0

Unpacked Size

13.7 kB

Total Files

4

Last publish

Collaborators

  • michaelptaylor