知识卡片
自定义规则先查可复用项
先检查内置规则和已有社区规则是否覆盖要求,再考虑用现成函数配置新规则。若 GET 的 operationId 只需约束前缀,Spectral 的 pattern 就能验证;需要更复杂逻辑才引入自定义函数。由团队承担函数的移植、测试及升级维护。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 自定义 Lint 与安全检查 10.1 The need for custom functions · 查看原书依据
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.
参考来源
- 位置:《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.