JSON模式,下拉列表控制显示哪些字段

时间:2018-09-24 14:46:07

标签: jsonschema

我具有以下json架构形式

我需要能够选择要运行的脚本,当前由oneOf进行控制,并且根据下拉菜单中选择的脚本,将显示要填充的不同选项。

问题是所选的脚本名称未以“ Create-ADUsers.psm1”形式提交的值传递

我一直在使用http://jeremydorn.com/json-editor/验证表单,并将no_additional_properties设置为true

我认为oneOf可能不是正确的解决方法,但我无法使用数组等使它正常工作。

import org.boon.Boon;

def jsonEditorOptions = Boon.fromJson(/{
disable_edit_json: false,
disable_properties: true,
no_additional_properties: true,
disable_collapse: true,
disable_array_add: false,
disable_array_delete: false,
disable_array_reorder: true,
show_errors: "always"
theme: "bootstrap3",
schema: {
    "title": "Which script do you want to run",
    "oneOf": [
        {
            "title": "----",
            "type": "null",
            "options": {
                "disable_collapse": true,
                "disable_edit_json": true,
                "disable_properties": true,
                "theme": "bootstrap3",
                "show_errors": "always"
            }
        },
        {
            "title": "Create-ADUsers.psm1",
            "type": "object",
            "properties": {
                "domain": {
                    "type": "string",
                    "propertyOrder": 1,
                    "default" : "@uhc"
                },
                "ou": {
                    "type": "string",
                    "title": "organizational unit ",
                    "propertyOrder": 2,
                    "default": "OU=Testing Users"
                },
                "ec2Instances": {
                    "type": "string",
                    "propertyOrder": 3,
                    "template": "i-XXXXXXXXXX"
                },
                "users": {
                    "type": "array",
                    "format": "table",
                    "title": "Users",
                    "uniqueItems": true,
                    "items": {
                        "type": "object",
                        "properties": {
                            "firstName": {
                                "type": "string",
                                "title": "First Name"
                            },
                            "lastName": {
                                "type": "string",
                                "title": "Last Name"
                            },
                            "email": {
                                "type": "string",
                                "title": "Email Address"
                            }
                        }
                    }
                }
            }
        },
        {
            "title": "Create-WorkspacesAlwaysON.psm1",
            "type": "object",
            "properties": {
                "ssmParams": {
                    "title": "Params",
                    "type": "string"
                }
            }
        }
    ]
}/);

return jsonEditorOptions;

我还希望能够有一个名为Env的下拉菜单,并在表单顶部添加值“ dev”,“ live”,无论选择哪个脚本,该下拉菜单始终显示,但是我认为这可能是太复杂了。

0 个答案:

没有答案