JSON格式"$ ref"错误 [英] JSON formatting "$ref" error

查看:257
本文介绍了JSON格式"$ ref"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查找导致以下JSON无效的原因.奇怪的是,它在网站中作为有效JSON散发,但在

I am trying to find what is making the following JSON invalid. The strange thing is that it passes off as valid JSON in this website but is invalid in this one

以下是架构:

http://pastebin.com/QPxEPjMT

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

The error logged on the second schema validation website is as follows:

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

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

有人可以澄清我的架构是否不正确,或者这与JSON架构本身中的一些歧义规则有关吗?

Can someone clarify whether my schema is incorrect or this is about some ambiguous rule in the JSON Schema itself?

推荐答案

您没有在根定义级别为"identifiable"类型的对象定义架构:

You do not have the schema defined for the object of type 'identifiable' on the root definitions level:

 {
    ...
    "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
        ...
  }
...
}

但是您已经在预订"类型的对象定义中定义了它.因此,该方案中的参考指向:

But you have it defined inside your definition of the object of type 'subscriptions'. So, the reference you have in the scheme is pointing to:

[root]/definitions/identifiable

但您可以使用它

[root]/definitions/subscriptions/definitions/identifiable

请修正您的引用. 顺便说一句,两个站点都将您的架构标记为无效.

Please, fix your reference. BTW, both of sites are marking your schema invalid.

这篇关于JSON格式"$ ref"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆