← 返回 Skills 市场
wangjipeng977

api-spec-to-mock-server

作者 王继鹏 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
37
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install wangjipeng-api-spec-to-mock-server
功能描述
Use when (1) user provides API spec in OpenAPI or Swagger format and needs a runnable mock server.
使用说明 (SKILL.md)

Api Spec To Mock Server

Use when (1) user provides API spec in OpenAPI or Swagger format and needs a runnable mock server.

Core Position

This skill solves the specific engineering problem of: user provides API spec in OpenAPI or Swagger format and needs a runnable mock server

This skill is NOT:

  • A general-purpose capability that activates on anything
  • A replacement for manual human judgment
  • A tool that stores state or remembers across sessions

This skill IS activated ONLY when the trigger conditions are explicitly met.

Modes

/api-spec-to-mock-server

Default mode. Performs the core task end-to-end.

When to use: User provides input matching the trigger conditions above.

Execution Steps

  1. Receive API spec — User provides an API specification document

    • Accepted formats: OpenAPI 3.x, Swagger 2.x, raw API description text
    • If the input is not recognizable as an API spec, state: "This skill generates a runnable mock server from an API specification (OpenAPI/Swagger). Please provide an API spec document."
  2. Parse spec structure — Extract the API contract:

    • Identify all endpoints (paths) and their HTTP methods (GET, POST, PUT, DELETE)
    • Extract request/response schemas and parameter definitions
    • Note authentication requirements, headers, and content types
    • Identify response status codes and example payloads
  3. Generate mock server — Create a runnable server with the spec:

    • Use a common mock server library (e.g., Prism, Mockoon, or a simple Express/Flask server)
    • Generate endpoint handlers that return realistic mock responses
    • Implement request validation matching the spec
    • Serve the mock server on a configurable port (default: 8080)
  4. Test endpoints — Verify the mock server behaves correctly:

    • Run a smoke test against the generated endpoints
    • Confirm response status codes match the spec
    • Verify content-type headers are correctly set
  5. Deliver with run instructions — Provide the server code and usage:

    • State how to start the server (command + port)
    • Provide example curl requests for key endpoints
    • Note any configuration needed (base URL, auth tokens)
    • Offer to adjust response payloads or add custom scenarios

Mandatory Rules

Do not

  • Do not make up facts or claim actions were taken that were not
  • Do not hardcode API keys — use os.getenv("API_KEY") instead
  • Do not store sensitive user data beyond the current session
  • Do not exceed token budget without warning the user first
  • Do not activate for off-topic requests — return a brief decline message

Do

  • Validate all inputs before acting
  • Handle errors gracefully with actionable error messages
  • Log actions taken for auditability
  • State explicitly when you are uncertain or data is insufficient

Quality Bar

A good output:

  • Solves exactly the problem described in the trigger conditions
  • Provides actionable result in the expected format within 3 turns
  • Handles error cases with specific guidance, not generic "try again"
  • States assumptions explicitly when input is ambiguous

A bad output:

  • Solves a different problem than the one triggered
  • Provides a generic "I can't help with that" without explaining why
  • Crashes, hangs, or returns malformed output on valid input
  • Activates for off-topic requests (false positive)

Good vs. Bad Examples

Scenario Bad Output Good Output
Trigger matched "I can help with that." + no action Correct transformation delivered in structured format
Invalid input Crash or wrong result "Missing required field: [X]. Please provide [Y]."
Ambiguous input Guesses and might be wrong States assumption and asks for confirmation
Off-topic request Attempts to help anyway "This skill activates when [trigger]. Please restate your request."

References

  • references/ — Detailed templates, schemas, and edge-case rules for this skill
安全使用建议
Before installing, treat this as a code-generation aid: provide only API specs you are comfortable sharing with the agent, keep any API key in an environment variable, and review generated server files before running them. The README is template-like, so rely on SKILL.md for the actual activation scope.
能力标签
requires-sensitive-credentials
能力评估
Purpose & Capability
The stated purpose is narrow and coherent: parse an OpenAPI/Swagger specification, generate a runnable mock server, test endpoints, and provide run instructions.
Instruction Scope
SKILL.md gives a clear activation boundary, but README.md and README_zh.md contain generic template text and placeholder trigger wording that could confuse users.
Install Mechanism
Installation is a normal ClawHub/manual skill copy flow; there are no install hooks, dependency scripts, or package downloads declared in the artifact.
Credentials
README declares API_KEY as required with little explanation, while SKILL.md says not to hardcode keys and to use os.getenv; credential handling should be documented more clearly but is not evidence of misuse.
Persistence & Privilege
The skill explicitly says it does not store state or remember across sessions, and the artifacts show no background workers, persistence setup, privilege escalation, or broad local indexing.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install wangjipeng-api-spec-to-mock-server
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /wangjipeng-api-spec-to-mock-server 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of the api-spec-to-mock-server skill. - Enables users to generate runnable mock servers from API specifications in OpenAPI or Swagger format. - Validates input, parses API spec structure, and generates endpoint handlers with realistic mock responses. - Provides usage instructions, curl examples, and configuration options for the generated server. - Includes detailed error handling and input validation to ensure reliable operation.
元数据
Slug wangjipeng-api-spec-to-mock-server
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

api-spec-to-mock-server 是什么?

Use when (1) user provides API spec in OpenAPI or Swagger format and needs a runnable mock server. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 37 次。

如何安装 api-spec-to-mock-server?

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

api-spec-to-mock-server 是免费的吗?

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

api-spec-to-mock-server 支持哪些平台?

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

谁开发了 api-spec-to-mock-server?

由 王继鹏(@wangjipeng977)开发并维护,当前版本 v1.0.0。

💬 留言讨论