CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

Schemathesis

$ schemathesis 社区开源 中风险
Schemathesis · 代码托管与研发协同 · MIT · macos / linux / windows

schemathesis 基于 Hypothesis 自动从 OpenAPI 和 GraphQL 规范生成边界测试用例,以发现 500 错误和契约偏离。支持 --checks all、--report json,junit、--max-examples 与 --no-color,适合确定性 CI 与 Agent 接口验证。

FCRS-1.0 综合评分
82 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install schemathesis
CLI vs MCP 选型建议 仅 CLI 可用

基于 OpenAPI/GraphQL 规范驱动的本地属性模糊测试器,自动批量发送生成的 HTTP 测试用例。

Agent 友好度体检单

✓ 原生 JSON 输出
✓ 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
✓ 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 21 / 25

支持无头执行、--report json,junit、--no-color、--include-method 范围过滤及可复现 --seed。

  • Structured --report json / ndjson / junit exports
  • Operation filters (--include-method, --include-path)
安全与权限边界 19 / 25

默认会向 POST/PUT/DELETE 发送随机载荷,除非通过 --include-method GET 限制;v4 已移除 --dry-run。

  • Mutating HTTP methods fuzzed unless explicitly filtered
  • Legacy --dry-run flag removed in Schemathesis v4
安装与运行摩擦 12 / 15

可通过 Homebrew、pip 与 uvx 在 macOS、Linux 与 Windows 安装,亦提供官方 Docker 镜像。

  • Cross-platform Python package and Homebrew formula
能力覆盖与边际价值 13 / 15

无需手写用例即可基于 OpenAPI/GraphQL 自动发现边界崩溃与契约漂移。

  • Stateful and property-based fuzzing via Hypothesis
维护与来源背书 9 / 10

由 Schemathesis 团队(schemathesis/schemathesis)积极维护,MIT 开源协议。

  • Rapid active development and v4 releases
文档与可验证性 8 / 10

文档与 --help 对检查项、过滤规则与报告格式说明详尽。

  • Detailed CLI guide on Read the Docs

安全边界、鉴权与放权指南

鉴权方式
无需鉴权 环境变量密钥
凭证存储位置

无内置凭证库;接口鉴权令牌通过 --header "Authorization: Bearer ..." 或 --auth 显式传递。

潜在副作用
只读查询 远端写入 破坏性删除
费用与配额提示

MIT 开源 Python CLI,完全免费。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# Schemathesis Agent Rules
- Restrict read-only probes with `--include-method GET` when testing shared environments.
- Never run full fuzzing (`POST`/`DELETE`) against production APIs—only target `localhost` or disposable test environments.
- Always pass `--no-color` and `--report json --report-json-path <file>` when parsing failures.

Agent 高频安全命令配方

只读查询(安全推荐)

仅对本地 OpenAPI 服务的 GET 接口做模糊测试
schemathesis run --include-method GET --checks all --max-examples 20 --no-color http://127.0.0.1:8000/openapi.json

将模糊测试限制在只读 GET 操作,每个接口最多生成 20 组边界用例。

受控写入与预演

运行完整契约检查并保存 JSON 与 JUnit 报告
schemathesis run --checks all --report json,junit --report-json-path report.json --report-junit-path junit.xml --no-color http://127.0.0.1:8000/openapi.json

对本地测试实例执行包含写操作在内的全量规范检查,并导出 JSON 与 JUnit 报告。

核心优势

  • + 自动对 OpenAPI 与 GraphQL 接口做模糊测试,暴露 5xx 崩溃与响应体偏差。
  • + 支持细粒度过滤(--include-method、--include-path)及 --report json,junit 导出。
  • + 支持随机种子(--seed)以便确定性复现问题。

注意事项与踩坑点

  • ! 除非显式限定 GET,否则默认会对 POST、DELETE 等写接口发起模糊请求。
  • ! Schemathesis v4 已移除 --dry-run,执行即会发送真实请求。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI