← 返回起始笔记位置

知识卡片

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

选择节点后运行校验

理解等级:中级

Spectral 规则通过 given 的 JSONPath 选目标字段,由 then 调函数。函数可约束输入类型,读取选项或文档上下文,然后返回零条或多条诊断。TypeScript 例以 startsWith 检查命名前缀。实现时由当前字段的上下文构造报告位置,函数尽量确定且无副作用,便于跨环境运行。

这张卡片看不懂?

已有反馈 · 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#p43) - 结论依据:原文列出目标、配置、上下文和诊断结果。 - 原始内容:So let me show you how to implement the getOperationIdConvention custom function. It should inspect the input target value, which is the operationId located by the given clause of the linting rule, and if it doesn’t start with retrieve or download, it should report a problem with the definition file.