SuperAPI AI 工具集

asyncapi-parser

编程与开发

查看项目

更新于 10-16 09:50

技能介绍

用途:解析 AsyncAPI 3.x(3.0、3.1)规范,并据此生成 Drift 测试用例。不支持 AsyncAPI 2.x,遇到 asyncapi: "2.x.x" 应告知用户并停止。

主要能力:定位操作(action、channel.$ref、messages[]、reply);递归解析 $ref 到 components.messages 与 components.schemas;识别 oneOf/anyOf/allOf/discriminator/const/correlationId/可选字段等 schema 模式;按 action 与 reply 自动判定执行模式(async-observe、async-inject、async-request-reply);枚举载荷变体并生成最小覆盖的 Drift 测试。

使用方式:先索引大文件(wc -l -c、grep -nE '^(operations|channels|components):'),用 awk 列出操作 ID,用 sed -n 读取有界范围,维护事实台账并去重 $ref。生成时命名规则为单变体 {operationId}{mode}、多变体 {operationId}{variant};始终包含 correlation-id 与 timeout-ms;async-observe 需 trigger 钩子,async-request-reply 不加 trigger,async-inject 用 probe 或 probe-topic。输出包含分析、Drift operations YAML、trigger/probe 钩子(服务相关处标 FILL_IN)与缺口说明。

适用场景:从 AsyncAPI 规范脚手架化 Drift 异步消息测试。

限制:仅支持 AsyncAPI 3.x;外部 $ref 无法解析时报告为缺口,不视为空 schema;递归引用保留回边并停止展开;具体服务钩子需自行填写。