允许基于相同基类型的所有之一

allow one of all based on the same base type

我有以下 json 架构:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "schema validating people and vehicles",
  "definitions": {
    "base": {
      "properties": {
        "age": {
          "type": "integer"
        }
      },
      "required": [
        "age"
      ]
    },
    "person": {
      "$ref": "#/definitions/base",
      "additionalProperties": false,
      "properties": {
        "firstName": {
          "type": "string"
        },
        "lastName": {
          "type": "string"
        },
        "sport": {
          "type": "string"
        }
      },
      "required": [
        "firstName"
      ]
    },
    "vehicle": {
      "$ref": "#/definitions/base",
      "additionalProperties": false,
      "properties": {
        "vehicle": {
          "type": "string"
        },
        "price": {
          "type": "integer"
        }
      }
    }
  },
  "type": "object",
  "oneOf": [
    {
      "$ref": "#/definitions/person",
    },
    {
      "$ref": "#/definitions/vehicle",
    }
  ]
}

我想让它验证

{"firstName":"John", "lastName":"Doe", "sport": "football", "age": 15}

及以下

{"type": "car", "price": 100, "age": 3}

我收到以下错误 JSON is valid against more than one schema from 'oneOf'. Valid schema indexes: 0, 1.

为什么它对不止一个有效? (firstName 仅在 person 中定义,type 仅在 vehicle 中定义。)

JSON 架构不支持继承。 参见: