Swagger 2.0中的JSON API示例
我正在尝试使用Swagger 2.0为端点创建示例响应Swagger 2.0中的JSON API示例,swagger,json-api,swagger-2.0,Swagger,Json Api,Swagger 2.0,我正在尝试使用Swagger 2.0为端点创建示例响应 200: description: Successful response schema: type: object $ref: "#/definitions/User" examples: application/vnd.api+json: - data: attributes:
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
,但它无法识别它。如果我删除了这些示例,我的规范将正常工作。你知道怎么具体说明吗
是的,尽管您可以定义一个这样的示例:
responses:
"200":
description: Successful response
schema:
$ref: '#/definitions/User'
examples:
application/json:
data:
id: 1
attributes:
attr1: value1
attr2: value2
有一个与mime类型相关的bug,您不能使用dots,这就是为什么我没有将应用程序/vnd.api+json放入的原因。这是由于用于验证的json模式中存在一个bug。虽然它已被修复,但需要几天时间才能用它更新编辑器。您不能使用引号吗?