← 返回 Skills 市场
charlie-morrison

api-mock-generator

作者 charlie-morrison · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
107
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install api-mock-generator
功能描述
Generate mock API servers from OpenAPI 3.x and Swagger 2.0 specs. Use when creating mock/stub APIs for frontend development, testing, demos, or CI. Generates...
使用说明 (SKILL.md)

API Mock Generator

Generate mock API servers and static fixtures from OpenAPI/Swagger specs. Contextual fake data (emails, names, UUIDs, etc.) based on property names and schema types.

Quick Start

# Start a live mock server
python3 scripts/generate_mock.py serve api.json

# Generate static JSON mock files
python3 scripts/generate_mock.py generate api.json -o mocks/

# List discovered routes
python3 scripts/generate_mock.py routes api.json

# Generate sample response for a specific endpoint
python3 scripts/generate_mock.py sample api.json /users

Commands

serve — Live Mock Server

python3 scripts/generate_mock.py serve spec.json [options]

Options:

  • --port, -p — port (default: 3000)
  • --host — host (default: 127.0.0.1)
  • --delay, -d — response delay in ms (simulate latency)
  • --error-rate, -e — random error rate 0.0-1.0 (simulate failures)

Features: CORS headers on all responses, path parameter matching, JSON responses with Content-Type headers.

generate — Static Mock Files

python3 scripts/generate_mock.py generate spec.json -o output_dir/

Creates one JSON file per route + manifest.json with route mapping. Useful for test fixtures or frontend stubs.

routes — Discover Endpoints

python3 scripts/generate_mock.py routes spec.json [--format text|json]

sample — Single Endpoint Preview

python3 scripts/generate_mock.py sample spec.json /users --method GET

Supported Specs

  • OpenAPI 3.x (JSON)
  • Swagger 2.0 (JSON)
  • YAML (requires pip install pyyaml)

Fake Data Generation

Property-name-aware generation:

Property pattern Generated data
*email* realistic email
*name* first/last/full name
*phone* formatted phone
*url*, *website* https URL
*city*, *country* real city/country
*id*, *uuid* UUID v4
*price*, *amount* currency-like number
*image*, *avatar* picsum.photos URL
*description*, *bio* lorem paragraph
*status* active/inactive/pending

Schema-aware: respects enum, example, default, format (date, date-time, email, uri, uuid, ipv4), minimum/maximum, minLength/maxLength, $ref, oneOf/anyOf/allOf.

Exit Codes

  • 0 — success
  • 1 — route not found (sample command)
  • 2 — spec parse error or system error
安全使用建议
This appears to be a straightforward local mock-server generator. Before running: (1) review the script if you plan to run it on a shared or production host; it binds to a host/port and will serve generated responses. (2) If you use YAML specs, installing PyYAML (pip install pyyaml) is required — installing packages pulls code from PyPI, so do that in a controlled environment if concerned. (3) The responses may contain external image URLs (picsum.photos) which cause clients to make outbound requests if fetched; run in an isolated network if you want no outbound traffic. (4) For large specs or public deployment, validate routing and CORS settings to avoid exposing sensitive data. Overall the skill is internally consistent with its stated purpose.
功能分析
Type: OpenClaw Skill Name: api-mock-generator Version: 1.0.0 The skill is a legitimate utility for generating mock API servers and static fixtures from OpenAPI/Swagger specifications. The code in scripts/generate_mock.py uses standard Python libraries, implements safe YAML parsing via yaml.safe_load, and includes proper path sanitization to prevent traversal during file generation. There are no indicators of data exfiltration, malicious execution, or harmful prompt injection.
能力评估
Purpose & Capability
Name/description match the included Python script and SKILL.md. The code implements OpenAPI/Swagger parsing and mock data generation; no unrelated services, cloud APIs, or credentials are requested.
Instruction Scope
Runtime instructions are limited to running the included Python script (serve/generate/routes/sample) against a local spec file. The instructions do not ask the agent to read unrelated system files, environment variables, or transmit data to external endpoints. Note: YAML support requires PyYAML if you provide YAML specs (the script warns and exits if not installed).
Install Mechanism
No install spec is provided (instruction-only). The bundle contains the runnable Python script only; nothing is downloaded or extracted during install.
Credentials
The skill declares no environment variables, credentials, or config paths. The script does not reference external secrets or request unrelated tokens.
Persistence & Privilege
always is false and the skill does not request persistent/privileged presence or modify other skills or system-wide settings. It runs as a normal user-space script (binds to host/port when serving).
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install api-mock-generator
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /api-mock-generator 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release
元数据
Slug api-mock-generator
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

api-mock-generator 是什么?

Generate mock API servers from OpenAPI 3.x and Swagger 2.0 specs. Use when creating mock/stub APIs for frontend development, testing, demos, or CI. Generates... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 107 次。

如何安装 api-mock-generator?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install api-mock-generator」即可一键安装,无需额外配置。

api-mock-generator 是免费的吗?

是的,api-mock-generator 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

api-mock-generator 支持哪些平台?

api-mock-generator 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 api-mock-generator?

由 charlie-morrison(@charlie-morrison)开发并维护,当前版本 v1.0.0。

💬 留言讨论