1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.link = void 0;
|
4 | var JSONSchema_1 = require("./types/JSONSchema");
|
5 | var lodash_1 = require("lodash");
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | function link(schema, parent) {
|
11 | if (parent === void 0) { parent = null; }
|
12 | if (!Array.isArray(schema) && !lodash_1.isPlainObject(schema)) {
|
13 | return schema;
|
14 | }
|
15 |
|
16 | if (schema.hasOwnProperty(JSONSchema_1.Parent)) {
|
17 | return schema;
|
18 | }
|
19 |
|
20 | Object.defineProperty(schema, JSONSchema_1.Parent, {
|
21 | enumerable: false,
|
22 | value: parent,
|
23 | writable: false
|
24 | });
|
25 |
|
26 | if (Array.isArray(schema)) {
|
27 | schema.forEach(function (child) { return link(child, schema); });
|
28 | }
|
29 |
|
30 | for (var key in schema) {
|
31 | link(schema[key], schema);
|
32 | }
|
33 | return schema;
|
34 | }
|
35 | exports.link = link;
|
36 |
|
\ | No newline at end of file |