2017-03-21 3 views
0

JSON 스키마를 검증 stdItem/children/0 경로에 대해 stdTypestdAttributes이 필요하다는 오류가 나타납니다. 속성이 있음을 알 수 있듯이 누락 된 것이 아닙니다.캔트 아이들에게 나는이 같은 JSON 스키마에서 일하고 있어요

속성의 순서를 변경하려고했지만 여전히 작동하지 않았습니다. 다음과 같은 오류가 계속 발생합니다.

--- BEGIN MESSAGES --- error: object has missing required properties (["stdAttributes","stdType"]) level: "error" schema: {"loadingURI":"#","pointer":"/definitions/stdItem"} instance: {"pointer":"/stdItem/children/0"} domain: "validation" keyword: "required" required: ["stdAttributes","stdType"] missing: ["stdAttributes","stdType"] --- END MESSAGES ---

아무도 내가 잘못하고있는 부분을 지적 할 수 있습니까?

답변

1

"children"속성을 선언 할 때 "stdItem"이라고 말하면 stdAttributes 및 stdType 속성이 있어야합니다. 대신 json에있는 것은 stdItem 유형의 "stdItem"속성입니다. 그래서 스키마에 해당 속성 선언 (stdItem)이 누락되었습니다. 나는 "stdItem"속성이 "아이들"의 항목 사양에 객체를 추가 해요

{ 
    "$schema": "http://json-schema.org/schema#", 
    "title": "Layout", 
    "description": "The layout created by the user", 
    "type": "object", 
    "definitions": { 
    "stdAttribute": { 
     "type": "object", 
     "required": ["attributeName","attributeValue"], 
     "properties": { 
     "attributeValue": { 
      "type": "string" 
     }, 
     "attributeName": { 
      "type": "string" 
     } 
     } 
    }, 
    "stdItem": { 
     "type": "object", 
     "required" : ["stdType","stdAttributes"], 
     "properties": { 
     "stdType": { 
      "enum": [ 
      "CONTAINER", 
      "TEXT", 
      "TEXTAREA", 
      "BUTTON", 
      "LABEL", 
      "IMAGE", 
      "MARCIMAGE", 
      "DATA", 
      "SELECT", 
      "TABLE" 
      ] 
     }, 
     "stdAttributes": { 
      "type": "array", 
      "items": { 
      "$ref": "#/definitions/stdAttribute" 
      }, 
      "minItems": 1 
     }, 
     "children": { 
      "type": "array", 
      "items": { 
      "type": "object", 
      "properties": { 
       "stdItem": { "$ref": "#/definitions/stdItem" } 
      } 
      } 
     } 
     } 
    } 
    }, 
    "properties":{ 
    "stdItem": { "$ref": "#/definitions/stdItem" } 
    }  
} 

주의 사항 :

이 스키마는 JSON 유효성을 검사합니다. (필자는 필요하다고 선언하지 않았지만 추가하고 싶을 수도 있음)