【问题标题】:Dredd (gavel) : Begin a Json Schema with an array (bug ?)Dredd(木槌):以数组开始 Json Schema(错误?)
【发布时间】:2014-11-19 17:28:40
【问题描述】:

我正在使用 Markdown 生成文档 (aglio)、生成模拟 (api-mock) 并检查完整性约束 (dredd)。

使用 Dredd,检查对象没有问题,PUT 或 POST 没有问题,但是列表有问题。

我的列表是数组,但是当我写这个模式时:

{
    "title": "Videos List",
    "type": "array",
    "items": {
            "type":"object",
            "required":false,
            "properties": {
                "id": {
                    "type": "string",
                    "required": true                                                            
                }
            },
            "required": true
    }
}

我总是遇到同样的错误:body: JSON schema is not valid! invalid type: object (expected [object Object]/array) at path "/items"

我一次又一次地尝试了 3 个小时,但我失败了。

请帮忙!

PS:对不起我的英语,我是法国人。

【问题讨论】:

标签: jsonschema apiary dredd


【解决方案1】:

是的,您的数据在该架构中再次正确。

这可能是您正在使用的验证器的特定问题(您没有提到哪个)。您可以尝试使用 {} 封装您的数据。我想它总是期望像这样的 JSON:

{
    [
        {
            "id": "ninon-retrouve-rudy",
            "title": "Ninon retrouve Rudy edited"
        },
        {
            "id": "ninon-retrouve-rudy-1",
            "title": "Ninon retrouve Rudy"
        }
    ]
}

请注意,您正在使用 Json-schema 的 Draft03。我建议你使用 Draft04(你的验证器可能已经过时了)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-07
    • 1970-01-01
    • 1970-01-01
    • 2020-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多