JSONSchema 数组中的每个条目具有不同的 oneOf 值
我有以下模式。 staticListDropdown是一个列表,对于数组dynamiClistPerarRayentry的每一行都是相同的
列表,我需要使用staticListDropdown的选定值作为键来填充该列表。当更改staticListDropdown选定的值时,应重新填充DynamiClistPerarRayentry中的项目,
我无法使DynamicListPerarRayentry正确填充填充
const DynamicListPerArrayEntry = [{ title: "None", const: null }].concat(map(bars[bar], (bar, barId) => {
return {
title: bar.name,
const: barId
}
}));
const staticListDropdown = [{ title: "None", const: null }].concat(map(props.properties, (prop1, prope1Id) => {
return {
title: prop1.name,
const: prope1Id
}
}));
const exampleSchema : JSONSchema7 = {
definitions: {
foo: {
title: "Foo",
type: "object",
properties: {
property1: {
type: "string",
title: "Property1",
oneOf: staticListDropdown,
},
bar: {
type: "string",
title: "Bar",
oneOf: DynamicListPerArrayEntry,
},
}
},
},
properties: {
foo: {
type: "array",
items: {
$ref: "#/definitions/foo"
}
},
}
}
I have the following schema. StaticListDropdown is a list which will be the same for every row of the array
DynamicListPerArrayEntry is a list of is a list that I need populating using the selected value of staticListDropdown as a key. When StaticListDropdown selected value is changed the items in DynamicListPerArrayEntry should be repopulated
I can't get the DynamicListPerArrayEntry to populate correctly
const DynamicListPerArrayEntry = [{ title: "None", const: null }].concat(map(bars[bar], (bar, barId) => {
return {
title: bar.name,
const: barId
}
}));
const staticListDropdown = [{ title: "None", const: null }].concat(map(props.properties, (prop1, prope1Id) => {
return {
title: prop1.name,
const: prope1Id
}
}));
const exampleSchema : JSONSchema7 = {
definitions: {
foo: {
title: "Foo",
type: "object",
properties: {
property1: {
type: "string",
title: "Property1",
oneOf: staticListDropdown,
},
bar: {
type: "string",
title: "Bar",
oneOf: DynamicListPerArrayEntry,
},
}
},
},
properties: {
foo: {
type: "array",
items: {
$ref: "#/definitions/foo"
}
},
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不熟悉打字稿,但是您的JSON模式不应该像这样吗?我只是把它放在编辑器中,并试图清理一些混乱:
请注意,我用实际数组更换了
Oneof
值,以使其在开发环境中工作。I am not familiar with TypeScript, but shouldn't your JSON schema be more like this? I just put it in an editor and tried to clean up the mess a little bit:
Please note, I replaced the
oneOf
values with actual arrays to make it working in the dev environment.