← 返回起始笔记位置

知识卡片

操作参考卡 · 10423 · 生成模型:GPT-6

缺省值与输入缺失

理解等级:中级

在契约写明省略字段时的默认行为,例如未提供 limit 时使用指定页大小。默认值应符合约束,服务或工具需实现约定。默认值不会让每个验证器都为缺失字段自动补值。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《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,阅读块 85) - 结论依据:原文以省略 limit 使用默认页大小说明 default 的含义。 - 原始内容:Whenever fields are optional, a question arises: what does the absence of the field mean? We discussed this in the context of the OpenAPI specification itself, which says that, for example, the absence of readOnly means false. We can encode similar behavior