知识卡片

操作参考卡 · 10370.b.1 · 生成模型:GPT-6

参数位置与模式分工

理解等级:中级

in: query 决定参数放在 URL 查询串,schema 规定值的类型和约束。maxRating 是数值,却仍要用上下界表达只接受 1 到 5。把一个规则仅写在文字描述里,机器无法凭数值类型推知范围。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Designing APIs with Swagger and OpenAPI》第03章《Our first taste of OpenAPI definitions》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch03.htm,阅读块 118) - 结论依据:添加 maxRating 的例子将 name、description、in、schema 作为不同字段。 - 原始内容:Here we have our original fragment (from listing 3.6), and to it we have added a parameters field, which is an array of parameters. You may have noticed the dash (-) before the name field, which indicates an array item that is