知识卡片
评分范围与整数
评分只接受 1 至 5 的整数时要同时指定 integer、minimum 为 1、maximum 为 5。边界 1 和 5 通过,1.43 和 6 失败。给字段设上下界只限制大小,并不会限制小数。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Describing API responses 5.4 JSON Schema · 查看原书依据
JSON Schema has two number types: number and integer. As you can see, the latter is a more limited variant that only includes negative, zero, and positive whole numbers. Perfect for our needs!
参考来源
- 位置:《Designing APIs with Swagger and OpenAPI》第05章《Describing API responses》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch05.htm,阅读块 89)
- 结论依据:数字范围测试承认小数仍通过,改 integer 后区分整数。
- 原始内容:JSON Schema has two number types: number and integer. As you can see, the latter is a more limited variant that only includes negative, zero, and positive whole numbers. Perfect for our needs!