|
8 | 8 | */
|
9 | 9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | 10 | exports.addUndefinedDefaults = void 0;
|
11 |
| -const utils_1 = require("../utils"); |
| 11 | +const interface_1 = require("../interface"); |
12 | 12 | const utility_1 = require("./utility");
|
13 | 13 | function addUndefinedDefaults(value, _pointer, schema) {
|
14 | 14 | if (typeof schema === 'boolean' || schema === undefined) {
|
@@ -47,41 +47,41 @@ function addUndefinedDefaults(value, _pointer, schema) {
|
47 | 47 | if (value == undefined) {
|
48 | 48 | newValue = {};
|
49 | 49 | }
|
50 |
| - else if (utils_1.isJsonObject(value)) { |
| 50 | + else if (interface_1.isJsonObject(value)) { |
51 | 51 | newValue = value;
|
52 | 52 | }
|
53 | 53 | else {
|
54 | 54 | return value;
|
55 | 55 | }
|
56 |
| - if (!utils_1.isJsonObject(schema.properties)) { |
| 56 | + if (!interface_1.isJsonObject(schema.properties)) { |
57 | 57 | return newValue;
|
58 | 58 | }
|
59 | 59 | for (const [propName, schemaObject] of Object.entries(schema.properties)) {
|
60 |
| - if (propName === '$schema' || !utils_1.isJsonObject(schemaObject)) { |
| 60 | + if (propName === '$schema' || !interface_1.isJsonObject(schemaObject)) { |
61 | 61 | continue;
|
62 | 62 | }
|
63 | 63 | const value = newValue[propName];
|
64 | 64 | if (value === undefined) {
|
65 | 65 | newValue[propName] = schemaObject.default;
|
66 | 66 | }
|
67 |
| - else if (utils_1.isJsonObject(value)) { |
| 67 | + else if (interface_1.isJsonObject(value)) { |
68 | 68 | // Basic support for oneOf and anyOf.
|
69 | 69 | const propertySchemas = schemaObject.oneOf || schemaObject.anyOf;
|
70 | 70 | const allProperties = Object.keys(value);
|
71 | 71 | // Locate a schema which declares all the properties that the object contains.
|
72 |
| - const adjustedSchema = utils_1.isJsonArray(propertySchemas) && |
| 72 | + const adjustedSchema = interface_1.isJsonArray(propertySchemas) && |
73 | 73 | propertySchemas.find((s) => {
|
74 |
| - if (!utils_1.isJsonObject(s)) { |
| 74 | + if (!interface_1.isJsonObject(s)) { |
75 | 75 | return false;
|
76 | 76 | }
|
77 | 77 | const schemaType = utility_1.getTypesOfSchema(s);
|
78 |
| - if (schemaType.size === 1 && schemaType.has('object') && utils_1.isJsonObject(s.properties)) { |
| 78 | + if (schemaType.size === 1 && schemaType.has('object') && interface_1.isJsonObject(s.properties)) { |
79 | 79 | const properties = Object.keys(s.properties);
|
80 | 80 | return allProperties.every((key) => properties.includes(key));
|
81 | 81 | }
|
82 | 82 | return false;
|
83 | 83 | });
|
84 |
| - if (adjustedSchema && utils_1.isJsonObject(adjustedSchema)) { |
| 84 | + if (adjustedSchema && interface_1.isJsonObject(adjustedSchema)) { |
85 | 85 | newValue[propName] = addUndefinedDefaults(value, _pointer, adjustedSchema);
|
86 | 86 | }
|
87 | 87 | }
|
|
0 commit comments