JSONSchema草稿v3验证错误

JSONSchema草稿v3验证错误,json,jsonschema,json-schema-validator,Json,Jsonschema,Json Schema Validator,我已经按照v3规范草案创建了一个JSON模式。架构如下所示: { "housePolicies": { "properties": { "guaranteePolicies": { "items": { "$ref": "#/housePolicies/guaranteePolicy" }, "type": "array" }, "spe

我已经按照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,但抱怨模式,在解析模式引用“#/housepolics/guarantepolicy/dow”时出错。我在报告中核实了参考资料的格式是否正确。有人能指出此模式中的错误在哪里吗?

您在
$ref
中使用了json路径,但仍然在对象上使用
id
。你不需要两者兼而有之,它们似乎相互矛盾。如果删除
id
,则模式有效。

如果将定义和模式属性分开,并且使用一致的缩进,则可以更清楚地看到不同部分的意图…