Swagger如何编写数组格式的模型
Swagger how to write a model which is array format
这样的json
[{xx:xx,xx1:xx1},{},...]
这里是一个get请求的model,直接return一个数组,不是很正规json,model怎么写?
/hsseventwebapi/v1/walking/events/{eventcd}/livecomments:
get:
operationId: イベント実況を返す
summary: 個人に関連するランキングを返す
description: "イベント実況を返す(取得したい実況一覧の開始日時を指定取得できる一覧は最大30件"
tags:
- Walking
parameters:
- name: eventcd
in: path
description: eventcd
required: true
type: integer
responses:
200:
description: OK
schema:
$ref: '#/definitions/LiveListModel'
这里是模型:
LiveListModel:
type: array
description: live list
items:
type: object
description: live item
properties:
eventNo:
type: string
description: eventNo
liveCommentYmdhms:
type: string
description: liveCommentYmdhms
liveComment:
type: string
description: liveComment
liveCommentSeq:
type: string
description: liveCommentSeq
targetAppUserNo:
type: string
description: targetAppUserNo
required:
- eventNo
- liveCommentYmdhms
- liveComment
- liveCommentSeq
- targetAppUserNo
这是ui
有两个liveListModel,无法解析。
您的规格是正确的。
Swagger Editor 和 UI 渲染数组模型如下:
ArrayModelName [ ItemModelName <item schema> ]
或者如果项目是对象:
ArrayModelName [ ItemModelName {
properties
}]
您图片上重复的模型名称是 Swagger 中的一个显示错误 Editor/UI。它应该会在本周晚些时候(9 月 15 日至 16 日?)即将发布的版本中修复。
在您的示例中,项目模型是内联的并且没有名称/title
,因此它应该呈现为无名称。
/hsseventwebapi/v1/walking/events/{eventcd}/livecomments:
get:
operationId: イベント実況を返す
summary: 個人に関連するランキングを返す
description: "イベント実況を返す(取得したい実況一覧の開始日時を指定取得できる一覧は最大30件"
tags:
- Walking
parameters:
- name: eventcd
in: path
description: eventcd
required: true
type: integer
responses:
200:
description: OK
schema:
type: array
items:
$ref: '#/definitions/LiveListItemModel'
LiveListItemModel:
type: object
description: live item
properties:
eventNo:
type: string
description: eventNo
liveCommentYmdhms:
type: string
description: liveCommentYmdhms
liveComment:
type: string
description: liveComment
liveCommentSeq:
type: string
description: liveCommentSeq
targetAppUserNo:
type: string
description: targetAppUserNo
required:
- eventNo
- liveCommentYmdhms
- liveComment
- liveCommentSeq
- targetAppUserNo
这样的json
[{xx:xx,xx1:xx1},{},...]
这里是一个get请求的model,直接return一个数组,不是很正规json,model怎么写?
/hsseventwebapi/v1/walking/events/{eventcd}/livecomments:
get:
operationId: イベント実況を返す
summary: 個人に関連するランキングを返す
description: "イベント実況を返す(取得したい実況一覧の開始日時を指定取得できる一覧は最大30件"
tags:
- Walking
parameters:
- name: eventcd
in: path
description: eventcd
required: true
type: integer
responses:
200:
description: OK
schema:
$ref: '#/definitions/LiveListModel'
这里是模型:
LiveListModel:
type: array
description: live list
items:
type: object
description: live item
properties:
eventNo:
type: string
description: eventNo
liveCommentYmdhms:
type: string
description: liveCommentYmdhms
liveComment:
type: string
description: liveComment
liveCommentSeq:
type: string
description: liveCommentSeq
targetAppUserNo:
type: string
description: targetAppUserNo
required:
- eventNo
- liveCommentYmdhms
- liveComment
- liveCommentSeq
- targetAppUserNo
这是ui
有两个liveListModel,无法解析。
您的规格是正确的。
Swagger Editor 和 UI 渲染数组模型如下:
ArrayModelName [ ItemModelName <item schema> ]
或者如果项目是对象:
ArrayModelName [ ItemModelName {
properties
}]
您图片上重复的模型名称是 Swagger 中的一个显示错误 Editor/UI。它应该会在本周晚些时候(9 月 15 日至 16 日?)即将发布的版本中修复。
在您的示例中,项目模型是内联的并且没有名称/title
,因此它应该呈现为无名称。
/hsseventwebapi/v1/walking/events/{eventcd}/livecomments:
get:
operationId: イベント実況を返す
summary: 個人に関連するランキングを返す
description: "イベント実況を返す(取得したい実況一覧の開始日時を指定取得できる一覧は最大30件"
tags:
- Walking
parameters:
- name: eventcd
in: path
description: eventcd
required: true
type: integer
responses:
200:
description: OK
schema:
type: array
items:
$ref: '#/definitions/LiveListItemModel'
LiveListItemModel:
type: object
description: live item
properties:
eventNo:
type: string
description: eventNo
liveCommentYmdhms:
type: string
description: liveCommentYmdhms
liveComment:
type: string
description: liveComment
liveCommentSeq:
type: string
description: liveCommentSeq
targetAppUserNo:
type: string
description: targetAppUserNo
required:
- eventNo
- liveCommentYmdhms
- liveComment
- liveCommentSeq
- targetAppUserNo