← 返回刚才阅读的位置

知识卡片

操作参考卡 · 10372.a · 生成模型:GPT-6

评分范围与整数

理解等级:中级

评分只接受 1 至 5 的整数时要同时指定 integer、minimum 为 1、maximum 为 5。边界 1 和 5 通过,1.43 和 6 失败。给字段设上下界只限制大小,并不会限制小数。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《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!