2017-11-10 7 views
5

के साथ JSONSchema सत्यापन विफलता ड्राफ्ट v3 विनिर्देशों के बाद मैंने JSON स्कीमा बनाया है। स्कीमा इस तरह दिखता है:

{ 
"$schema": "http://json-schema.org/draft-03/schema#", 
"additionalProperties": false, 
"type": "object", 
"properties": { 
    "ExecutionPlanList": { 
     "type": "array", 
     "items": [{ 
      "type": "object", 
      "properties": { 
       "model": { 
        "required": true, 
        "properties": { 
         "featureList": { 
          "required": true, 
          "items": { 
           "properties": { 
            "featureName": { 
             "type": ["string", "null"] 
            }, 
            "featureType": { 
             "type": "string" 
            } 
           }, 
           "type": "object" 
          }, 
          "type": "array" 
         }, 
         "modelId": { 
          "required": true, 
          "type": "string" 
         } 
        }, 
        "type": "object" 
       }, 
       "cascadeSteps": { 
        "required": false, 
        "items": { 
         "properties": { 
          "binaryModel": { 
           "$ref": "#/properties/ExecutionPlanList/items/properties/model", 
           "required": true 
          }, 
          "threshold": { 
           "required": true, 
           "default": "0.0", 
           "maximum": 100.0, 
           "type": "number" 
          }, 
          "backupModel": { 
           "$ref": "#/properties/ExecutionPlanList/items/properties/model", 
           "required": true 
          } 
         } 
        }, 
        "type": "array" 
       }, 
       "marketplaceId": { 
        "required": true, 
        "type": "integer" 
       } 
      } 
     }] 
    } 
}, 
"required": true 
} 

अनिवार्य रूप से, executionPlanList मॉडल और cascadeStep की सूची होती है, और प्रत्येक cascadeStep एक संख्या के साथ दो मॉडल शामिल हैं। तो मैं कैस्केडस्टेप में मॉडल के लिए स्कीमा का फिर से उपयोग करने की कोशिश कर रहा हूं, लेकिन सत्यापन (https://www.jsonschemavalidator.net/) Could not resolve schema reference '#/properties/ExecutionPlanList/items/properties/model' के साथ विफल रहा है।

इस स्कीमा के साथ क्या गलत है इस बारे में किसी भी संकेतक की सराहना करेंगे।

उत्तर

3

क्या एक 'परिभाषा' जोड़ने के बारे में और इस तरह देखें:

{ 
"$schema": "http://json-schema.org/draft-03/schema#", 
"additionalProperties": false, 
"type": "object", 
"definitions": { 
     "model": { 
      "required": true, 
      "properties": { 
       "featureList": { 
        "required": true, 
        "items": { 
         "properties": { 
          "featureName": { 
           "type": ["string", "null"] 
          }, 
          "featureType": { 
           "type": "string" 
          } 
         }, 
         "type": "object" 
        }, 
        "type": "array" 
       }, 
       "modelId": { 
        "required": true, 
        "type": "string" 
       } 
      }, 
      "type": "object" 
     } 
}, 
"properties": { 
    "ExecutionPlanList": { 
     "type": "array", 
     "items": [{ 
      "type": "object", 
      "properties": { 
       "model": { 
        "$ref" : "#/definitions/model" 
       }, 
       "cascadeSteps": { 
        "required": false, 
        "items": { 
         "properties": { 
          "binaryModel": { 
           "$ref" : "#/definitions/model", 
           "required": true 
          }, 
          "threshold": { 
           "required": true, 
           "default": "0.0", 
           "maximum": 100.0, 
           "type": "number" 
          }, 
          "backupModel": { 
           "$ref" : "#/definitions/model", 
           "required": true 
          } 
         } 
        }, 
        "type": "array" 
       }, 
       "marketplaceId": { 
        "required": true, 
        "type": "integer" 
       } 
      } 
     }] 
    } 
}, 
"required": true 
} 
4

यह #/गुण/ExecutionPlanList/आइटम/0/गुण/मॉडल '

स्कीमा केवल पहले आइटम की पुष्टि करता है, वैसे होना चाहिए।

+0

धन्यवाद। क्या आप दूसरे भाग पर विस्तारित कर सकते हैं "केवल पहले आइटम को मान्य करता है" – Stormbringer

+0

"आइटम" मान एक सरणी है, इसलिए स्कीमा केवल सरणी में पहले आइटम पर लागू होती है। यह ठीक है अगर इसका इरादा है, लेकिन यह भी एक आम गलती है ... – esp

+0

ओह..यह निश्चित रूप से मेरा इरादा नहीं है। चूंकि v3 शब्दकोश का समर्थन नहीं करता है, यहां स्कीमा का पुन: उपयोग करने का अनुशंसित तरीका क्या है? – Stormbringer

संबंधित मुद्दे