1

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

+ Model (application/json)

    + Body

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

    + Schema

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

当我在 Apiary 中运行模拟服务时,它可以工作,但在 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 的错误?

4

1 回答 1

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 } } }

于 2014-07-30T05:54:40.990 回答