json-schema-deref-sync
Dereference JSON pointers in a JSON schemas with their true resolved values. Basically a lighter, synchronous version of json-schema-deref but omits web references.
Installation
npm install json-schema-deref-sync
Overview
Let's say you have the following JSON Schema:
Sometimes you just want that schema to be fully expanded, with $ref
's being their (true) resolved values:
This utility lets you do that:
var deref = ;var myschema = ; var fullSchema = ;
API Reference
Object
| Error
deref(schema, options) ⇒ Derefs $ref
's in JSON Schema to actual resolved values. Supports local, and file refs.
Kind: global function
Returns: Object
| Error
- the deref schema oran instance of Error
if error.
Param | Type | Description |
---|---|---|
schema | Object |
The JSON schema |
options | Object |
options |
options.baseFolder | String |
the base folder to get relative path files from. Default is process.cwd() |
options.failOnMissing | Boolean |
By default missing / unresolved refs will be left as is with their ref value intact. If set to true we will error out on first missing ref that we cannot resolve. Default: false . |
options.mergeAdditionalProperties | Boolean |
By default properties in a object with $ref will be removed in the output. If set to true they will be added/overwrite the output. This will use lodash's merge function. Default: false . |
options.removeIds | Boolean |
By default $id fields will get copied when dereferencing. If set to true they will be removed. Merged properties will not get removed. Default: false . |
options.loaders | Object |
A hash mapping reference types (e.g., 'file') to loader functions. |