知识卡片

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

路径参数必填

理解等级:中级

URL 模板 /reviews/{reviewId} 缺少 ID 就无法组成特定资源的地址。声明 name 与占位符相同、in 为 path,并写 required: true。查询参数负责路径之外的额外输入,可按需要设为可选。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Designing APIs with Swagger and OpenAPI》第06章《Creating resources》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch06.htm,阅读块 150) - 结论依据:原文说明路径参数的 required 不允许取 false。 - 原始内容:Note that besides in being set to path, the only extra field we require (compared to query parameters) is the required field. A path parameter cannot be optional, according to the OpenAPI spec.