知识卡片
数组约束有独立层次
items 约束每个元素,minItems 和 maxItems 约束数量,uniqueItems 约束值的重复。字段是否存在由外层 required 控制。验证缺失、空数组、重复元素与非法元素四种状态,能分别发现所缺约束。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Improving input validation with advanced JSON Schema 19.2 Supported validations · 查看原书依据
The common behavior of JSON Schema validation keywords applies here as well, meaning their absence indicates that there shouldn’t be any constraints. Hence, by default, an array could have as few as 0 items, and there’s no upper bound except what the
参考来源
- 位置:《Designing APIs with Swagger and OpenAPI》第19章《Improving input validation with advanced JSON Schema》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch19.htm,阅读块 66)
- 结论依据:原文说明不设数量和唯一性时,数组可为空且允许重复。
- 原始内容:The common behavior of JSON Schema validation keywords applies here as well, meaning their absence indicates that there shouldn’t be any constraints. Hence, by default, an array could have as few as 0 items, and there’s no upper bound except what the