SuperAPI AI 工具集

api-contract

编程与开发

查看项目

更新于 10-16 00:23

技能介绍

用途:从需求或领域描述出发,生成契约优先(contract-first)的 API 规范,适用于在实现之前先定义接口契约的开发流程。

主要能力:支持三类契约格式。未指定格式时按描述自动判断:出现 API、REST、endpoint 推荐 OpenAPI 3.1;出现 events、messages、streaming 推荐 AsyncAPI 3.0;出现 gRPC、high-performance、internal 推荐 Protocol Buffers。生成内容包含完整 schema 定义、操作/方法、认证配置、错误响应 schema 及各操作的示例,并输出契约文件(YAML 或 .proto)、端点/频道/服务摘要、实现说明与建议的测试场景。

使用方式:通过斜杠命令调用,可传入自然语言需求,并用 format 参数指定格式。例如: /api-contract "user registration with email verification" /api-contract "order events for downstream systems" format=asyncapi /api-contract "high-performance inventory service" format=protobuf

工作流程:分析需求识别领域实体、所需操作、通信模式与消费者;选择契约格式;调用对应技能(openapi-design、asyncapi-design、protobuf-design);设计资源模型(实体、值对象、枚举、关系、请求/响应包装);生成契约;最后输出结果。可选集成 requirements-elicitation、enterprise-architecture、test-strategy、systems-design。

限制:资料未提供具体实现细节、依赖版本、错误处理边界、收费与平台信息。