Dredd (gavel) : Begin a Json Schema with an array (bug ?)

338 Views Asked by At

I am using Markdown for Generate documentation (aglio), generate mocks (api-mock) and check the integrity constraints (dredd).

With Dredd, no problem for check an object, no problem for PUT or POST, but I have a problem with lists.

My lists are arrays, but when I write this schema :

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

I get same error all the time: body: JSON schema is not valid! invalid type: object (expected [object Object]/array) at path "/items"

I've tried, again and again, 3 hours, but I failed.

Please help!

PS : sorry for my English, I'm french.

1

There are 1 best solutions below

0
On

Yes, your data is correct again that schema.

It might be a specific problem of the validator your are using (you did not mention which). You can try to enclose your data with {}. I guess it is expecting allways a JSON like this:

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

Be aware also that your are using Draft03 of Json-schema. I suggest you to use Draft04 (your validator might be obsolete).