yaml - 如何在 Swagger 的 YAML 中创建相同类型的嵌套对象数组?
问题描述
我正在尝试在 swagger 中创建一个 YAML 模式,它具有如图所示的树状结构。数组中的数组中应该有数组。使用$ref
来指代相同的结构,但我变得空白。它没有生成完整的结构。
Asset:
type: array
items:
id:
type: string
serial:
type: number
...
...
Asset:
type: array
items:
$ref: '#/components/schemas/Asset'
解决方案
试试这个:
Asset:
type: array
items:
type: object
properties:
id:
type: string
example:
"typeExample"
serial:
type: number
example:
123
推荐阅读
- php - PHP-FPM sock 无法在 Nginx 上连接
- node.js - 随机得到不存在“Access-Control-Allow-Origin”标头
- python - 棘手的问题 - 框架内的框架
- javascript - Node.js - 如何在 javascript 块上使用在 server/app.js 中完成的 mysql 查询
- c# - 在开发阶段引用解决方案之外的包/项目
- json - 如何使用@StateObject 修改布尔值?
- python - 列表无意同时更改
- c# - 如何将一些 html 元素转换为 span 元素并从中提取坐标?
- python - while 循环没有进行到下一次迭代
- redis - 使用 serde_json 解析 JSON 字符串