← 返回刚才阅读的位置

知识卡片

操作参考卡 · 10296.b.1.b.2.b.1 · 生成模型:未记录

遗留接口用精确Lint例外

理解等级:中级

给遗留 API 渐进接入共享规则集。用 overrides 的文件定位加 JSON Pointer 针对旧节点调低级别,新增节点仍沿用默认规则。指针将路径中的斜杠转义成 ~1,本例的花括号在 URI 片段编码成 %7B 和 %7D。例外宜小且可追踪,能安全修订旧契约时再清理。

把例外限定到某个对象或操作需要[[JSON Pointer定位]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • API Lint 与设计一致性 3.9 Overriding API linting rules · 查看原书依据

      The way Spectral does this is called overrides. Spectral overrides allow you to customize the same ruleset for different projects or OpenAPI documents. Overrides specify the OpenAPI documents and object to be overridden (using an override reference made up of a file path glob and a JSON pointer) and the rule name to switch whose severity should be modified, as illustrated in figure 3.5.

    参考来源

    - 位置:《Automating API Delivery APIOps with OpenAPI》《第 03 章 API Lint 与设计一致性》(3.9 Overriding API linting rules;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-3.xhtml#p122) - 结论依据:原文说明覆盖由文件 glob、JSON Pointer 和规则名及级别组成,从而将变化限制在特定节点。 - 原始内容:The way Spectral does this is called overrides. Spectral overrides allow you to customize the same ruleset for different projects or OpenAPI documents. Overrides specify the OpenAPI documents and object to be overridden (using an override reference made up of a file path glob and a JSON pointer) and the rule name to switch whose severity should be modified, as illustrated in figure 3.5.