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類型,就需要層級定義。

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