我正在尝试使用 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
,但它无法识别它。如果我删除这些示例,我的规范就可以工作。知道如何指定它吗?
最佳答案
是not fully implemented yet ,尽管您可以像这样定义一个示例:
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
关于swagger - Swagger 2.0 中的 JSON API 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31458005/