aladin-api-pilot

An API contract testing workshop from Aladdin: converts OpenAPI/Swagger/Postman/cURL into runnable test suites, local mock servers, contract validations, and visual reports with one action, forming an end-to-end API quality verification chain.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "aladin-api-pilot" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-6b2e6d53691173ae1f093df404417596f7e787fc5827967c36ec7bd8e9f39e8a. Verify the upstream source and version against https://skillhub.cn/skills/user_d18c97ea/aladin-api-pilot before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

An API contract testing workshop from Aladdin: converts OpenAPI/Swagger/Postman/cURL into runnable test suites, local mock servers, contract validations, and visual reports with one action, forming an end-to-end API quality verification chain.

0 Downloads

Introduction source: third_party · user_d18c97ea · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Not specified in the source documentation.
Inputs and outputs
Translation pending; see source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: aladin-api-pilot
slug: aladin-api-pilot
version: 1.0.0
displayName: 阿拉丁·API契约测试工坊|从接口文档到可运行测试套件
summary: 阿拉丁出品的 API 契约测试工坊:把 OpenAPI/Swagger/Postman/cURL 一键变成可运行测试套件、本地 Mock Server、契约校验与可视化报告,比单点 test-gen 工具多做一整条 API 质量收口链。
description: 阿拉丁·API契约测试工坊把接口文档(OpenAPI 3/Swagger 2/Postman v2.1/cURL)一键转化为四件套——可运行测试套件(pytest+requests 或 Newman+Postman 或 纯JS)、本地 Mock Server、契约校验(状态码/响应schema/延迟)、HTML+MD 测试报告;相比 skillhub 上飙升的单点 test-gen 工具(只生成零散测试代码),本技能多了多源导入归一、基于参数类型与必填的智能用例设计(正常/边界/异常/鉴权四类)、Mock 桩与契约断言,且导入与报告脚本纯标准库零依赖;适合后端/前端/测试工程师做接口回归、对接第三方 API 验收、前后端并行开发时的本地桩。触发词:API测试、接口测试、契约测试、contract testing、OpenAPI测试、Swagger测试、Postman转测试、生成接口测试用例、接口回归、mock server、接口文档校验、API test generator、从接口文档生成测试。
category: 开发者工具
license: MIT
platforms:
  - WorkBuddy
  - QClaw
  - ima
homepage: https://skillhub.cn
author: adam
company: 阿拉丁
tags:
  - API测试
  - 接口测试
  - 契约测试
  - contract testing
  - OpenAPI测试
  - Swagger测试
  - Postman转测试
  - 接口测试用例
  - 接口回归
  - mock server
  - 接口文档校验
  - API test generator
  - 自动化测试
  - 开发者工具
  - pytest
  - 接口质量
  - API quality
  - 前后端联调
agent_created: true

阿拉丁·API 契约测试工坊(aladin-api-pilot)

阿拉丁出品。你有 OpenAPI/Swagger/Postman,但「写接口测试」每一步都在切换工具:手动造请求、补边界值、对状态码、等后端联调。这个技能把接口文档一次性变成四件套——可运行测试套件 + 本地 Mock Server + 契约校验 + 可视化报告,让 API 质量收口在一条本地流水线上。

它解决什么痛点

开发者在 skillhub 上能找到一堆单点测试/接口工具,但没有一个把它们串起来:

现有单点技能 只做 不做
各类 test-gen / test-case-generator 零散生成测试代码 不解析接口文档、不做契约校验、不起 Mock
Postman/Newman 类 跑集合 需手工建集合、不校验 schema、不生成报告
mock 类单点 起桩 不联动测试、不读 OpenAPI 自动建桩

本技能 = 多源导入 + 智能用例设计 + 可运行测试 + Mock 桩 + 契约校验 + 报告,一次交付,导入/报告脚本纯标准库、零依赖。

与 skillhub 现有技能的差异化

能力 单点 test-gen Postman/Newman 阿拉丁·API契约测试工坊(本款)
多源文档导入(OpenAPI/Swagger/Postman/cURL) ❌ 仅 Postman ✅ 统一归一为 endpoints.json
智能用例设计(正常/边界/异常/鉴权) ❌ 只生成空壳 ❌ 手工 ✅ 基于参数类型/必填/schema(Hy3)
可运行测试(pytest/Newman/JS) ⚠️ 零散片段 ✅ 需手工集合 ✅ 一键生成完整套件
本地 Mock Server(读文档自动建桩) ❌ ❌ ✅ stdlib http.server,零依赖
契约校验(状态码/响应schema/延迟) ❌ ⚠️ 弱 ✅ 内置 schema 校验器
可视化报告(HTML+MD/覆盖率) ❌ ❌ ✅ 计划覆盖率+实测结果双视图
脚本依赖 各异 Node ✅ 导入/报告纯标准库

与同门 aladin-code-pilot 的差异(避免混淆)

维度 aladin-code-pilot(已发布) 本款 aladin-api-pilot
测试对象 函数/类(单元级,mock 依赖) HTTP 接口/端点(契约/集成级)
输入 代码目录 / git diff OpenAPI/Swagger/Postman/cURL
产出 单测 + 修复补丁 + 提交 接口测试套件 + Mock + 契约报告
适合 给 utils.py 补单测、提交前体检 给 /api/users 做回归、对接第三方 API 验收

两者互补不重叠:先用本款验证「接口对不对」,再用 aladin-code-pilot 体检「代码好不好」。

何时触发

  • "帮我把这个 OpenAPI/Swagger 文档生成接口测试" / "API test generator from OpenAPI"
  • "把这个 Postman 集合转成可运行的 pytest 测试" / "Postman 转测试"
  • "给这几个接口写正常/边界/异常用例" / "接口回归一下"
  • "前端要联调但后端没好,起个 Mock Server" / "mock server"
  • "校验一下第三方 API 返回的字段和文档一致吗" / "契约测试"
  • 用户贴出 cURL 命令、Swagger URL(导出 JSON 后)、一段接口文档,希望一次性拿到「测试 + Mock + 报告」

何时不触发

  • 用户要单元测试/函数级测试(给某个函数补单测)——用同门 aladin-code-pilot 更贴合。
  • 用户要从零写接口业务代码——这是编码任务,本技能只做「文档→测试/Mock/报告」的收口。
  • 用户要做性能压测/混沌/安全渗透——本技能是契约/功能级测试,不是运行时压测。
  • 用户只想手工调一个接口看返回(无测试资产沉淀需求)——直接用 agent-browser/cURL 即可。
  • 用户在做强合规涉密环境且禁止本地留痕——虽本技能纯本地,仍需先确认合规策略。

核心能力(多源导入 + 智能设计 + 本地增值)

  1. 多源导入归一:api_ingest.py 解析 OpenAPI 3 / Swagger 2(JSON)、Postman v2.1、cURL 文本 → 统一 endpoints.json(路径、方法、参数、请求体 schema、响应、示例值)。
  2. 智能用例设计(Hy3 语义推理):读 endpoints.json,为每个端点生成 正常 / 边界 / 异常(负向) / 鉴权 四类用例,依据参数类型、是否必填、枚举、schema 自动推断边界值与负向输入,产出 test_plan.json。
  3. 可运行测试生成:api_gen.py --plan test_plan.json 产出
    • tests/test_api.py:pytest + requests,含状态码/响应 schema/延迟断言;
    • mock_server.py:stdlib http.server 本地桩,按文档示例响应,前后端并行开发零等待;
    • postman_collection.json:Newman 可跑集合(可选)。
  4. 契约校验:内置轻量 schema 校验器(标准库实现,无需 jsonschema),断言状态码、必填字段、字段类型、枚举、响应头、约定延迟上限。
  5. Mock Server:一键 python mock_server.py --port 8080,从 endpoints.json 自动建桩,支持路径参数回显、示例响应、CORS。
  6. 测试报告:api_report.py 把计划覆盖率(端点/用例类型分布)与实测结果渲染为 HTML 看板 + Markdown,含通过率、分级、逐用例明细。
  7. 零依赖机械脚本:导入/报告脚本仅用 Python 标准库,不联网、不上传;生成测试用 requests/pytest(测试期通用依赖)。

工作流(5 步)

① 导入    api_ingest.py --in <openapi.json|postman.json|curl.txt> --out endpoints.json
② 设计    Hy3 读 endpoints.json → 按四类法产出 test_plan.json(见 references/test-design-playbook.md)
③ 生成    api_gen.py --plan test_plan.json --target pytest --out tests/  → test_api.py + mock_server.py + postman_collection.json
④ 运行    pytest tests/  →  test_results.json(或 Newman 跑集合)
⑤ 收口    api_report.py --in test_results.json --html report.html --md report.md

使用方式

脚本零硬依赖(仅标准库);生成的测试文件用 requests/pytest 运行(测试期通用依赖,按需 pip install requests pytest)。

PY="C:/Users/adam/.workbuddy/binaries/python/versions/3.13.12/python.exe"

# ① 导入:OpenAPI / Swagger / Postman / cURL 任一
"$PY" scripts/api_ingest.py --in assets/sample_openapi.json --out endpoints.json
#   也支持目录批量:"$PY" scripts/api_ingest.py --in ./docs --out endpoints.json

# ② 智能体读取 endpoints.json → 按 references/test-design-playbook.md 产出 test_plan.json

# ③ 生成测试套件 + Mock + Postman(target: pytest | newman | js)
"$PY" scripts/api_gen.py --plan test_plan.json --target pytest --out tests/

# ④ 运行(需 requests + pytest)
"$PY" -m pytest tests/ -v           # 或:newman run postman_collection.json

# ⑤ 收口报告(实测结果;无实测时传计划覆盖率也可出计划视图)
"$PY" scripts/api_report.py --in test_results.json --html report.html --md report.md

# 额外:本地 Mock(无需后端即可联调,自动读取同目录 mock_data.json)
"$PY" tests/mock_server.py --port 8080

测试计划 JSON 速查(Hy3 产出)

{
  "base_url": "https://api.example.com",
  "endpoints": [
    {
      "id": "getUser",
      "path": "/users/{id}",
      "method": "GET",
      "cases": [
        {"name":"正常-存在用户","type":"happy","expect_status":200,
         "expect_schema":{"type":"object","required":["id","name"]}},
        {"name":"边界-id=0","type":"boundary","params":{"id":0},"expect_status":200},
        {"name":"异常-id非数字","type":"negative","params":{"id":"abc"},"expect_status":400},
        {"name":"鉴权-缺token","type":"auth","headers":{},"expect_status":401}
      ]
    }
  ]
}

输入输出规范

输入:

  • 接口文档:openapi.json / swagger.json(OpenAPI 2/3)、postman.json(v2.1)、或 .txt/.http 内的 cURL 命令;也支持含上述文件的目录批量导入。
  • 可选:base_url(运行测试/起 Mock 的目标地址)、target(pytest/newman/js)、延迟上限(--max-latency)。

输出:

  • endpoints.json:归一化接口清单(中间产物)。
  • test_plan.json:智能体设计的用例计划(中间产物)。
  • tests/test_api.py / postman_collection.json:可运行测试。
  • mock_server.py:本地桩(可选)。
  • report.html + report.md:覆盖率/通过率/明细看板。

输出位置: 由各脚本 --out / --html / --md 参数指定,默认当前目录。

能力边界

能做:

  1. 解析 OpenAPI 2/3、Postman v2.1、cURL 并归一为统一接口模型。
  2. 为每个端点设计正常/边界/异常/鉴权四类用例(Hy3 语义推断)。
  3. 生成 pytest+requests / Newman / 纯 JS 三种测试套件,含契约断言。
  4. 从文档一键起本地 Mock Server(标准库实现)。
  5. 渲染计划覆盖率与实测结果的 HTML/MD 报告。

不能做:

  1. 不替代性能压测/混沌/安全渗透(是功能与契约级测试)。
  2. 不自动发请求攻击生产(默认打 base_url,需用户给定,且建议先对 Mock 跑)。
  3. 不解析非标准/私有 RPC(仅覆盖 REST/HTTP 语义接口)。
  4. 不保证发现所有业务缺陷(覆盖率受文档完整度与可见 schema 限制)。
  5. 生成的测试依赖 requests/pytest 才能运行(脚本本身零依赖,但测试运行需测试期依赖)。

重要约束

  • 不外发、不上传:导入/报告脚本全部本地运行,接口文档与报告留在本机(→ Trust)。
  • 先 Mock 后真实:建议先对本地 Mock 跑通,再指向真实 base_url,避免误伤生产(→ Reliability)。
  • 不篡改业务语义:Mock 仅按文档示例响应,不改变接口既定行为(→ Convention)。
  • 降级可用:无 PyYAML 时 YAML 文档给出明确转换提示,JSON 始终可用;无被测框架仍输出计划与报告(→ Reliability)。
  • 零依赖透明:导入/报告脚本仅用 Python 标准库,SKILL.md 已写明运行方式(→ Adaptability)。
  • 口径一致:跨来源统一 endpoints.json 模型,测试/报告可比、可追溯(→ Convention)。

安全说明

  • 导入/报告脚本仅用 Python 标准库,不发起任何网络请求、不上传任何接口文档或报告。
  • 生成的测试默认访问你指定的 base_url;请在确认目标环境(建议先用本地 Mock)后再指向真实服务。
  • 不接管账号、不自动推送,产出与动作分离,适合含内部接口定义的私有仓库。

参考文档(渐进式披露)

文件 用途 加载时机
references/api-formats.md 支持的输入格式 + 示例(OpenAPI/Postman/cURL)与字段映射 导入前,确认文档形态
references/test-design-playbook.md 四类用例设计法则 + 边界/负向/鉴权推断规则 第②步设计用例时
references/mock-strategies.md Mock Server 用法、CORS、路径参数、与真实环境切换 起 Mock / 联调时
references/usage-examples.md 3 个完整场景 + 最佳实践 + FAQ 首次使用 / 排错时

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value92/100

Highlights

  • 解决开发者高频刚需:将接口文档一键转化为测试套件+Mock+报告
  • 填补 skillhub 上单点工具的空白,提供端到端闭环能力
  • 明确区分与同门 aladin-code-pilot 的边界,定位精准
Trigger Precision95/100

Highlights

  • 触发词覆盖全面且精准,包含中英文变体
  • 边界清晰,明确列出适用与不适用场景
  • 与现有技能差异化描述充分,避免混淆
Structure and Standards94/100

Highlights

  • 5步工作流清晰,含端到端 bash 示例
  • frontmatter 完整,单文件长度合规
  • 引用文档命名规范,渐进式披露设计合理
Execution Reliability93/100

Highlights

  • 工具来源明确,依赖透明(标准库+测试期通用依赖)
  • 覆盖主要异常场景,有降级机制
  • 安全约束清晰,建议先 Mock 后真实,避免误伤生产
Evidence Verifiability (mean of the first four)94/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 120
Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • api.example.com
  • skillhub.cn

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Not specified in the source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.