-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathreadme.hbs
More file actions
93 lines (78 loc) · 2.3 KB
/
readme.hbs
File metadata and controls
93 lines (78 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# json-schema-deref-sync
[](https://www.npmjs.com/package/json-schema-deref-sync)
[](https://travis-ci.org/bojand/json-schema-deref-sync)
[](https://standardjs.com)
[](https://raw.githubusercontent.com/bojand/json-schema-deref-sync/master/LICENSE)
Dereference JSON pointers in a JSON schemas with their true resolved values.
Basically a lighter, synchronous version of [json-schema-deref](https://github.com/bojand/json-schema-deref) but omits web references.
## Installation
`npm install json-schema-deref-sync`
## Overview
Let's say you have the following JSON Schema:
```json
{
"description": "Just some JSON schema.",
"title": "Basic Widget",
"type": "object",
"definitions": {
"id": {
"description": "unique identifier",
"type": "string",
"minLength": 1,
"readOnly": true
}
},
"properties": {
"id": {
"$ref": "#/definitions/id"
},
"foo": {
"$ref": "http://www.mysite.com/myschema.json#/definitions/foo"
},
"bar": {
"$ref": "bar.json"
}
}
}
```
Sometimes you just want that schema to be fully expanded, with `$ref`'s being their (true) resolved values:
```json
{
"description": "Just some JSON schema.",
"title": "Basic Widget",
"type": "object",
"definitions": {
"id": {
"description": "unique identifier",
"type": "string",
"minLength": 1,
"readOnly": true
}
},
"properties": {
"id": {
"description": "unique identifier",
"type": "string",
"minLength": 1,
"readOnly": true
},
"foo": {
"description": "foo property",
"readOnly": true,
"type": "number"
},
"bar": {
"description": "bar property",
"type": "boolean"
}
}
}
```
This utility lets you do that:
```js
var deref = require('json-schema-deref-sync');
var myschema = require('schema.json');
var fullSchema = deref(myschema);
```
## API Reference
{{>all-docs~}}