我已根据草案v3规范创建了一个JSON模式。架构如下所示:
{
"housePolicies": {
"properties": {
"guaranteePolicies": {
"items": {
"$ref": "#/housePolicies/guaranteePolicy"
},
"type": "array"
},
"specialRequirements": {
"items": {
"$ref": "#/housePolicies/specialRequirement"
},
"type": "array"
},
"chainCode": {
"required": true,
"type": "string",
"description": "Unique identifier of the chain"
},
"losRestrictions": {
"items": {
"$ref": "#/housePolicies/losRestriction"
},
"type": "array"
},
"specialEvents": {
"items": {
"$ref": "#/housePolicies/specialEvent"
},
"type": "array"
},
"propertyCode": {
"required": true,
"type": "string",
"description": "Unique identifier of the property in the chain"
}
},
"specialRequirement": {
"id": "specialRequirement",
"properties": {
"minLOS": {
"type": "integer",
"description": "Minimum stay, in days, that applies for a special requirement restriction.\nOptional: If no input provided, there is no minimum LOS required for that period.",
"format": "int64"
},
"startDate": {
"required": true,
"type": "string",
"description": "Date when a special requirement restriction starts",
"format": "date"
},
"endDate": {
"required": true,
"type": "string",
"description": "Date when a special requirement restriction ends",
"format": "date"
}
}
},
"guaranteePolicy": {
"dow": {
"id": "dow",
"properties": {
"monday": {
"required": true,
"type": "boolean"
},
"tuesday": {
"required": true,
"type": "boolean"
},
"friday": {
"required": true,
"type": "boolean"
},
"wednesday": {
"required": true,
"type": "boolean"
},
"thursday": {
"required": true,
"type": "boolean"
},
"sunday": {
"required": true,
"type": "boolean"
},
"saturday": {
"required": true,
"type": "boolean"
}
}
},
"id": "guaranteePolicy",
"properties": {
"startDate": {
"required": true,
"type": "string",
"description": "Date when a guarantee policy starts",
"format": "date"
},
"endDate": {
"required": true,
"type": "string",
"description": "Date when a guarantee policy ends",
"format": "date"
},
"guaranteeRequiredDow": {
"items": {
"$ref": "#/housePolicies/guaranteePolicy/dow"
},
"required": true
}
}
},
"losRestriction": {
"id": "losRestriction",
"properties": {
"startDate": {
"required": true,
"type": "string",
"description": "Date when a length of stay restriction starts",
"format": "date"
},
"max": {
"type": "integer",
"description": "In case max is not provided it measn that there is no maximum length of stay restrictions.\nOptional: If no input provided, there is no maximum length restriction.",
"format": "int64"
},
"endDate": {
"required": true,
"type": "string",
"description": "Date when a length of stay restriction ends",
"format": "date"
},
"min": {
"type": "integer",
"description": "In case min is not provided it means that there is no minimum length of stay restrictions.\nOptional: If no input provided, there is no minimum length restriction.",
"format": "int64"
}
}
},
"specialEvent": {
"id": "specialEvent",
"properties": {
"startDate": {
"required": true,
"type": "string",
"description": "Date when a special event restriction starts",
"format": "date"
},
"endDate": {
"required": true,
"type": "string",
"description": "Date when a special event restriction ends",
"format": "date"
}
}
},
"id": "housePolicies"
},
"$schema": "http://json-schema.org/draft-03/schema#",
"id": "request",
"properties": {
"housePolicies": {
"items": {
"$ref": "#/housePolicies"
},
"required": true
}
}
}
我现在正在尝试针对它验证一些JSON,但是jsonschemavalidator抱怨架构,在解析架构引用时出错,#/ housePolicies / guaranteePolicy / dow'。我在documentation中验证了引用的格式正确。任何人都可以指出这个架构中的错误在哪里?
答案 0 :(得分:1)
您在$ref
中使用过json-path,但仍在对象上使用id
。你不需要两者,它们似乎是冲突的。如果您删除id
,则架构可以正常运行。