0

我试图找出导致以下 JSON 无效的原因。奇怪的是它在这个网站上作为有效的 JSON 传递,但在这个网站上是无效

这是架构:

http://pastebin.com/QPxEPjMT

第二个架构验证网站上记录的错误如下:

Error when resolving schema reference '#/definitions/identifiable'. 

Path 'definitions.subscription.allOf[0]', line 19, position 17.

有人可以澄清我的架构是否不正确,或者这是关于 JSON 架构本身的一些模棱两可的规则吗?

4

1 回答 1

0

您没有在根定义级别为“可识别”类型的对象定义架构:

 {
    ...
    "definitions": {
         ...
        "identifiable": {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "id": "http://api.sprint.com/schema/identifiable#",
                "title": "Identifiable Schema",
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "READ ONLY. The id of the resource."
                    }
                },
                "required": [
                    "id"
                ],
                "additionalProperties": true
        ...
  }
...
}

但是您在“订阅”类型的对象的定义中定义了它。因此,您在方案中的参考指向:

[root]/definitions/identifiable

但你有它:

[root]/definitions/subscriptions/definitions/identifiable

请修复您的参考。顺便说一句,这两个站点都将您的架构标记为无效。

于 2017-07-24T15:41:08.473 回答