← 返回刚才阅读的位置

知识卡片

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

Spectral诊断定位违规

理解等级:中级

用 spectral lint <定义文件> --ruleset <规则集> 选择要检查的契约和规则。需要看启用的规则数或被检查文件可加 --verbose。报告按行列号、级别、规则名、问题消息和文档路径定位。商品目录案例的响应媒体类型应按 JSON:API 约定定义,这是一条特定规则集的约束。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • API Lint 与设计一致性 3.4 Running Spectral to check for compliance · 查看原书依据

      You can see that the problem output starts with a line and column number (41:30), a problem severity (error), the name of the rule in the ruleset file that was violated (response-content-type), the output message associated with the rule (All JSON:API response bodies MUST be returned . . .), and finally the location in the API definition file that has the problem (paths./v1/catalog/categories.get.responses[200].content.application/json).

    参考来源

    - 位置:《Automating API Delivery APIOps with OpenAPI》《第 03 章 API Lint 与设计一致性》(3.4 Running Spectral to check for compliance;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-3.xhtml#p51) - 结论依据:原文逐项解释诊断输出及其如何定位商品目录案例的媒体类型问题。 - 原始内容:You can see that the problem output starts with a line and column number (41:30), a problem severity (error), the name of the rule in the ruleset file that was violated (response-content-type), the output message associated with the rule (All JSON:API response bodies MUST be returned . . .), and finally the location in the API definition file that has the problem (paths./v1/catalog/categories.get.responses[200].content.application/json).