阵列响应体的蜂房蓝图降价

时间:2014-07-30 01:09:04

标签: jsonschema apiblueprint apiary

我有一个REST服务,它返回一个字符串数组(即不是一个对象)。 Apiary的相关蓝图降价如下:

+ Model (application/json)

    + Body

            [
                "element1",
                "element2",
                "element3"
            ]

    + Schema

            {
                "type": "array",
                "items": {
                    "type": "string"
                }
            }

当我在Apiary运行模拟服务时,它可以工作,但我在蜂房交通检查员中收到以下错误:

This API request was compared to a documented resource but was found invalid. 
Check your request headers and body below. 
... 
JSON schema is not valid! invalid type: object (expected [object Object]/array) 
at path "/items"

是否有一个技巧可以使这个工作(改变降价),或者这是Apiary的错误?

1 个答案:

答案 0 :(得分:0)

Apiary支持JSON Schema草案3,这使用JSON模式生成器 - http://www.jsonschema.net/

{ "type":"object", "$schema": "http://json-schema.org/draft-03/schema", "id": "http://jsonschema.net", "required":false, "properties":{ "0": { "type":"string", "id": "http://jsonschema.net/0", "required":false }, "1": { "type":"string", "id": "http://jsonschema.net/1", "required":false }, "2": { "type":"string", "id": "http://jsonschema.net/2", "required":false } } }