问题描述
我希望我的 OpenAPI 规范显示两个对象的列表,如下所示,但我无法这样做。
[
{
"studentID": 1,"studentName": "Ram"
},{
"studentID": 2,"studentName": "Shyam"
}
]
editor.swagger.io 中的 Swagger 规范:
解决方法
example
关键字应与 items
处于同一级别:
200:
description: success response
content:
application/json:
schema:
type: array
items:
properties:
studentID:
type: integer
studentName:
type: string
example:
- { "studentID": 1,"studentName": "Ram" }
- { "studentID": 2,"studentName": "Shyam" }