重新定义引用的JSON架构的必需属性

重新定义引用的JSON架构的必需属性,json,schema,jsonschema,Json,Schema,Jsonschema,我的模式使用“$schema”:http://json-schema.org/draft-04/schema,并在其定义中包含以下内容: "lineitem": { "name": "Item", "description": "Single item found in an order.", "type": "object", "additionalProperties": true, "allOf":[{ "ref": "../line-item.js

我的模式使用
“$schema”:http://json-schema.org/draft-04/schema,并在其定义中包含以下内容:

"lineitem": {
    "name": "Item",
    "description": "Single item found in an order.",
    "type": "object",
    "additionalProperties": true,
    "allOf":[{ "ref": "../line-item.json" }]
}
我的问题是:我需要这个
行项目.json中的所有内容,除了一个必需的属性
status
,它是一个对我没有用处的枚举。我需要能够覆盖
状态
,而无需更改引用的架构。我确实需要一个状态,并且我有一个包含正确信息的定义文件。但我如何将其纳入我的项目<代码>状态
对于这两个项目都是必需的,但含义不同

我试过这两种方法,但都失败了,我觉得这一定是可能的,但我做错了什么:

"lineitem": {
    "name": "Item",
    "description": "Single item found in an order.",
    "type": "object",
    "additionalProperties": true,
    "allOf":[{ "ref": "../line-item.json" }],
    "properties": {
        "status": { "$ref": "definitions.json#/definitions/status" }
    }
}

"lineitem": {
    "name": "Item",
    "description": "Single item found in an order.",
    "type": "object",
    "additionalProperties": true,
    "allOf":[{ "ref": "../line-item.json" }],
    "definitions": {
        "status": { "$ref": "definitions.json#/definitions/status" }
    }
},

我完全知道解决这个问题的最佳方法是重新定义
行项目.json
,这样
状态
不是必需的,或者每个使用都有不同的定义,
行项目
模式的用户在使用时会选择。但是我没有权限更改该模式,并且很难获得该模式的许多受影响用户的认可。

JSON模式中的所有约束都是可添加的,这意味着您不能删除添加的内容,而是需要从一开始就利用组合。我的建议是拆分
行item.json

行项目.json

{
  "allOf": {
    "properties": {
      "status": {"enum": [1,2,3]}
    },
    "allOf": {
      "$ref": "line-item-without-status.json"
    }
  }
}
{
  "type": "object",
  "properties": {
    "sharedProp": {
      "type": "string"
    }
  }
}
具有其他状态定义的行项目:

{
  "allOf": {
    "properties": {
      "status": {"$ref": "#/definitions/status"}
    },
    "allOf": {
      "$ref": "line-item-without-status.json"
    }
  }
}
无状态的共享
行项目。json

{
  "allOf": {
    "properties": {
      "status": {"enum": [1,2,3]}
    },
    "allOf": {
      "$ref": "line-item-without-status.json"
    }
  }
}
{
  "type": "object",
  "properties": {
    "sharedProp": {
      "type": "string"
    }
  }
}

您能详细说明一下您的评论吗?您的建议是拆分line-item.json,但正如我在OP中所说的,我无权更改line-item模式。