小编Pix*_*lex的帖子

针对包含多个架构定义的 JSON 架构进行验证

我正在创建一个用于 Postman 的 JSON 架构,其中包含一些架构定义。我根据架构验证的 JSON 需要与架构定义之一匹配。

示例模式

{
  "oneOf": [
    {
      "$ref": "#/definitions/schema1"
    },
    {
      "$ref": "#/definitions/schema2"
    },
    {
      "$ref": "#/definitions/schema3"
    }
  ],
  "definitions": {
    "schema1": {
      "type": "object",
      "properties": {
        "propertyA": {
          "type": "string"
        }
      },
      "required": [
        "propertyA"
      ]
    },
    "schema2": {
      "type": "object",
      "properties": {
        "propertyB": {
          "type": "string"
        }
      },
      "required": [
        "propertyB"
      ]
    },
    "schema3": {
      "type": "object",
      "properties": {
        "propertyC": {
          "type": "string"
        }
      },
      "required": [
        "propertyC"
      ]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

示例 …

json jsonschema postman

3
推荐指数
1
解决办法
2216
查看次数

标签 统计

json ×1

jsonschema ×1

postman ×1