2015-09-08 5 views
1

Я создал схему JSON, следуя спецификациям проекта v3. Схема выглядит следующим образом:Ошибка проверки JSONSchema v3

{ 
"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/Доу. Я подтвердил в documentation, что ссылки помещены в надлежащем формате. Может ли кто-нибудь указать, где ошибка в этой схеме?

+0

Было бы намного яснее видеть намерение разных частей, если вы разделяете определения и свойства схемы, и если вы используете последовательный отступ ... – fiddur

ответ

1

Вы использовали json-path в своем $ref, но при этом используете объекты id. Вам не нужны оба, и они кажутся противоречивыми. Если вы удалите id, ваша схема будет работать.

 Смежные вопросы

  • Нет связанных вопросов^_^