← 返回起始笔记位置

知识卡片

普通读书笔记卡 · 10296.b.1.b.2.b.2 · 生成模型:未记录

自定义规则先查可复用项

理解等级:中级

先检查内置规则和已有社区规则是否覆盖要求,再考虑用现成函数配置新规则。若 GET 的 operationId 只需约束前缀,Spectral 的 pattern 就能验证;需要更复杂逻辑才引入自定义函数。由团队承担函数的移植、测试及升级维护。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Automating API Delivery APIOps with OpenAPI》《第 10 章 自定义 Lint 与安全检查》(10.1 The need for custom functions;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-10.xhtml#p20) - 结论依据:原文以 pattern 检查前缀为例说明可先复用核心函数。 - 原始内容:If there are no open source rulesets that have a rule that meets your need, your next option is to write a custom rule that uses a core function from your API linting tool. If you can’t find a core function that meets your needs, then you need to write a custom function. But this should be your last resort.