schema-components 1.12.3 → 1.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/walker.mjs +32 -24
- package/package.json +1 -1
package/dist/core/walker.mjs
CHANGED
|
@@ -198,7 +198,7 @@ function walk(schema, options = {}) {
|
|
|
198
198
|
isNullable: false,
|
|
199
199
|
isOptional: false,
|
|
200
200
|
defaultValue: void 0,
|
|
201
|
-
|
|
201
|
+
refResults: /* @__PURE__ */ new Map()
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
function walkNode(schema, ctx) {
|
|
@@ -220,31 +220,39 @@ function walkNode(schema, ctx) {
|
|
|
220
220
|
return walkUnion(oneOf, ctx);
|
|
221
221
|
}
|
|
222
222
|
const ref = getString(schema, "$ref");
|
|
223
|
-
if (ref !== void 0
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
223
|
+
if (ref !== void 0) {
|
|
224
|
+
const cached = ctx.refResults.get(ref);
|
|
225
|
+
if (cached !== void 0) return cached;
|
|
226
|
+
const resolved = resolveRef(schema, ctx.rootDocument, /* @__PURE__ */ new Set());
|
|
227
|
+
const placeholder = {
|
|
228
|
+
type: "unknown",
|
|
229
|
+
editability: "editable",
|
|
230
|
+
meta: {},
|
|
231
|
+
constraints: {}
|
|
232
|
+
};
|
|
233
|
+
ctx.refResults.set(ref, placeholder);
|
|
234
|
+
const result = walkNode(resolved, ctx);
|
|
235
|
+
Object.assign(placeholder, result);
|
|
236
|
+
return placeholder;
|
|
237
|
+
}
|
|
238
|
+
const enumValues = getArray(schema, "enum");
|
|
239
|
+
if (enumValues !== void 0) return walkEnum(schema, enumValues, ctx);
|
|
240
|
+
if ("const" in schema) return walkLiteral(schema, ctx);
|
|
241
|
+
const type = getString(schema, "type");
|
|
242
|
+
if (type === void 0) return buildField(schema, "unknown", ctx);
|
|
243
|
+
if (type === "string") return walkString(schema, ctx);
|
|
244
|
+
if (type === "number" || type === "integer") return walkNumber(schema, ctx);
|
|
245
|
+
if (type === "boolean") return walkBoolean(schema, ctx);
|
|
246
|
+
if (type === "null") return buildField(schema, "null", ctx);
|
|
239
247
|
if (type === "object") {
|
|
240
|
-
const properties = getObject(
|
|
241
|
-
if (properties !== void 0) return walkObject(
|
|
242
|
-
const additionalProps = getObject(
|
|
243
|
-
if (additionalProps !== void 0) return walkRecord(
|
|
244
|
-
return buildField(
|
|
248
|
+
const properties = getObject(schema, "properties");
|
|
249
|
+
if (properties !== void 0) return walkObject(schema, properties, ctx);
|
|
250
|
+
const additionalProps = getObject(schema, "additionalProperties");
|
|
251
|
+
if (additionalProps !== void 0) return walkRecord(schema, additionalProps, ctx);
|
|
252
|
+
return buildField(schema, "object", ctx);
|
|
245
253
|
}
|
|
246
|
-
if (type === "array") return walkArray(
|
|
247
|
-
return buildField(
|
|
254
|
+
if (type === "array") return walkArray(schema, ctx);
|
|
255
|
+
return buildField(schema, "unknown", ctx);
|
|
248
256
|
}
|
|
249
257
|
function walkString(schema, ctx) {
|
|
250
258
|
if (getString(schema, "format") === "binary") return buildField(schema, "file", ctx);
|