JSONSchema array

如果定义类型是array,需要定义items的属性,如果items的类型是object,那么在相关属性中需要定义object具有的属性。下面是array的示例:

 "paramtable": {
      "type": "array",
      "description": "流程变量表",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "变量名称"
          },
          "type": {
            "enum": [ "string", "int", "bool", "float" ],
            "description": "变量类型"
          },
          "desc": {
            "type": "string",
            "description": "变量描述"
          },
          "extern_store": {
            "type": "string",
            "description": "外部存储"
          }
        },
        "additionalProperties": false
      }
    }

在上面的示例中,数组中可以包括的对象具有的属性是name,type,desc和exten_store,并且不允许其它属性。如果属性中包括object类型,就需要层级定义。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章