2016-08-31 2 views

답변

2

$ref은 스키마를 참조하는 데 사용되어야한다

샘플 스키마 : 같은

{ 
    "$schema": "http://json-schema.org/draft-04/schema#", 
    "type": "object", 
    "properties": { 
     "card": { 
      "type": "object", 
      "properties": { 
       "id": { 
        "type": "integer" 
       }, 
       "value": { 
        "type": "string", 
        "enum": {"$ref" : "reference to a file having list of enums"} 
        //I want to refer to a specific enum array (say value1's array) 
       } 
      } 
     } 
    }, 
    "required": [ 
     "card" 
    ] 
} 

열거 형 파일입니다. 그래서, 당신은 이런 식으로 할 수 있습니다.

{ 
    "$schema": "http://json-schema.org/draft-04/schema#", 
    "type": "object", 
    "properties": { 
     "card": { 
      "type": "object", 
      "properties": { 
       "id": { "type": "integer" }, 
       "value": { "$ref" : "/schemas/valueEnum.json" } 
      } 
     } 
    }, 
    "required": ["card"] 
} 

/schemas/valueEnum.json

{ "enum": ["foo", "bar"] }