知识卡片
数组items约束元素
JSON Schema 描述数组时,type: array 只说明容器类型,items 进一步规定每个元素的结构。订单项数组可用 items 指向对象模型,确保数组元素按预期包含产品、尺寸和数量,而非任意值。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 5 章《Documenting REST APIs with OpenAPI》(源文件:_epub-src/OEBPS/Text/05.htm)
- 结论依据:原文示例用 `type: array` 和 `items` 描述订单项数组,并明确 `items` 定义数组内各元素类型。
- 原始内容:Array types require an additional property in their schema, which is the items property that defines the type of each of the elements contained in the array. In this case, each of the elements in the array is an object that represents an item in the order.