使用jsonSchema在其他选择框的基础上加载选择框选项

使用jsonSchema在其他选择框的基础上加载选择框选项,json,jsonschema,json-schema-validator,Json,Jsonschema,Json Schema Validator,我正在使用jsonschema生成表单并验证这些表单 下面是一个json示例: { "title": "Microsoft Account Request", "readOnly": false, "$schema": "http://json-schema.org/draft-04/hyper-schema", "description": "Microsoft Azure Account Request Product Specification", "propertie

我正在使用jsonschema生成表单并验证这些表单

下面是一个json示例:

{
  "title": "Microsoft Account Request",
  "readOnly": false,
  "$schema": "http://json-schema.org/draft-04/hyper-schema",
  "description": "Microsoft Azure Account Request Product Specification",
  "properties": {
    "product": {
      "title": "Product",
      "dataBinding": {"references": ["SPEC_ID#/properties/service"]},
      "properties": {
        "offers": {
          "title": "Product Offers",
          "propertyOrder": 1,
          "type": "array",
          "uniqueItems": true,
          "format": "tabs",
          "items": {
            "title":"Product Offer",
            "properties": {
              "category": {
                "title": "Category",
                "readOnly": false,
                "unique":true,
                "strictProperties": true,
                "enum": [
                  "Cloud Services",
                  "Virtual Machines",
                  "Azure App Service",
                  "Batch"


                ],
                "options": {
                    "dependencies": [
                      {"id":"subcategoryAdd", "value":true}
                    ]
                  },
                "description": "Select category",
                "propertyOrder": 1,
                "type": "string"
              },
              "subcategory": {
                  "id":"subcategoryAdd",
                "title": "Sub - Category",
                "readOnly": false,
                "strictProperties": true,
                "description": "Select Sub-Category",
                 "options": {
                    "hide_display": true
                  },
                "enum": [
                  "Build and Deployment",
                  "Application Insights"
                ],
                "propertyOrder": 2,
                "type": "string"
              }
            },
            "type": "object"
          }
        }

      },
      "type": "object"
    }
  },
  "type": "object"
}
和样本输出:

在输出表单中,我突出显示了其选择框中的子类别选项,该选项应基于所选类别加载

例如,如果我选择
batch
,则子类别选项a、b、c应显示在子类别的选择框中,如果我选择
Azure app service
,则子类别选项d、e、f应显示在子类别的选择框中

我尝试使用
依赖项
,但徒劳无功。此外,我还尝试使用前面提到的
watch
enumSource
来实现这一点

任何帮助都是值得的


谢谢

可以使用以下JSON模式验证类别/子类别关系

{
  "type": "object",
  "anyOf": [
    {
      "properties": {
        "category": { "enum": ["foo"] },
        "subCategory": { "enum": ["asdf", "jkl;"] }
      }
    },
    {
      "properties": {
        "category": { "enum": ["bar"] },
        "subCategory": { "enum": ["asdf", "qwer", "uiop"] }
      }
    }
  ]
}
但是,这并不意味着您使用的表单生成器能够基于此创建表单。如果可以的话,我会印象深刻的