6

我正在尝试使用 Swagger 2.0 为端点创建示例响应。

    200:
      description: Successful response
      schema:
        type: object
        $ref: "#/definitions/User"
      examples:
        application/vnd.api+json:
            - data:
                attributes:
                  full_name: John Appleseed
            - data:
                attributes:
                  full_name: Mike Appleseed

我的 api 消费和生产application/vnd.api+json,但它不会识别它。如果我删除这些示例,我的规范就会起作用。知道如何指定它吗?

错误

4

1 回答 1

9

它还没有完全实现,尽管你可以像这样定义一个例子:

   responses:
    "200":
      description: Successful response
      schema: 
        $ref: '#/definitions/User'
      examples:
        application/json:
          data:
            id: 1
            attributes:
              attr1: value1
              attr2: value2

有一个与 mime 类型相关的错误,你不能使用点,这就是我没有放application/vnd.api+json 的原因

于 2015-07-29T01:24:15.360 回答