【发布时间】:2016-08-26 12:02:43
【问题描述】:
我正在为我的 API 使用 swagger 文档。现在真的被 yaml 代码打动了。 我真的想要来自以下 json 代码的响应部分的 yaml 代码
{
"status":0,
"gtasks":[],
"purchased":[],
"scnt":0
}
任何帮助将不胜感激..
【问题讨论】:
标签: yaml swagger swagger-ui
我正在为我的 API 使用 swagger 文档。现在真的被 yaml 代码打动了。 我真的想要来自以下 json 代码的响应部分的 yaml 代码
{
"status":0,
"gtasks":[],
"purchased":[],
"scnt":0
}
任何帮助将不胜感激..
【问题讨论】:
标签: yaml swagger swagger-ui
空白数组只是这些键没有项目时的状态。但是,如果有任何项目,则数组将被这些项目填充。在这种情况下,您仍然需要定义这些数组中的内容。
这是YourObjectName 的架构定义,它表示:
{
"status":0,
"gtasks":[],
"purchased":[],
"scnt":0
}
查看 cmets 以使用数据类型或其他模式对象填充数组类型。
definitions:
YourObjectName:
type: object
required:
- status
properties:
status:
type: integer
format: int32 # you need
gtasks:
type: array
items: # Need to define item type, could be any data type of object
type: string
purchased:
type: array
items:
type: string # For reference to different schema object use $ref: "#/definitions/PurchasedItems"
scnt:
type: integer
format: int32
最后,如果您需要帮助,请参阅http://editor.swagger.io/ 中的“PetStore”示例 API 规范
祝你好运。
【讨论】: