Skip to content

Commit 4dd046b

Browse files
committed
fix(core): 修复 anyof 后代存在 $ref可能无法回填的问题
fix #59
1 parent 7153c10 commit 4dd046b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/lib/utils/schema/validate.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ export function getMatchingOption(formData, options, rootSchema, haveAllFields =
259259
// Create an "anyOf" schema that requires at least one of the keys in the
260260
// "properties" object
261261
const requiresAnyOf = {
262+
// 如果后代节点存在 $ref 需要正常引用
263+
...(rootSchema.definitions ? {
264+
definitions: rootSchema.definitions
265+
} : {}),
262266
anyOf: Object.keys(option.properties).map(key => ({
263267
required: [key],
264268
})),
@@ -291,6 +295,7 @@ export function getMatchingOption(formData, options, rootSchema, haveAllFields =
291295
// 如果编辑回填数据的场景 可直接使用 required 判断
292296
if (!haveAllFields) delete augmentedSchema.required;
293297

298+
294299
if (isValid(augmentedSchema, formData)) {
295300
return i;
296301
}

0 commit comments

Comments
 (0)