AGENT SKILL

api-mock-generator

Derive API mocks and contract tests from schemas or observed interfaces without inventing behavior.

License 许可
MIT
最近更新
2026-11-09
Stars
★ 0
Forks
0

01 前言 Front Matter

name
api-mock-generator
risk
low
source
openclawskills.net
aliases
[ "api", "mock", "test", "contract", "openapi", "swagger" ]
enabled
true
version
1.0.0
category
media_and_utilities
keywords
[ "api", "mock", "test", "openapi", "swagger", "rest", "contract" ]
metadata
{ "openclaw": { "requires": { "env": [], "bins": [] }, "primaryEnv": null } }
triggers
[ "Generate API mocks", "Create mock API", "API testing", "Mock endpoints" ]
description
Derive API mocks and contract tests from schemas or observed interfaces without inventing behavior.
required_tools
[ "test-framework" ]

03 SKILL.md 正文

API Mock & Contract Generator

Purpose

Generate API mocks and contract tests from OpenAPI schemas or observed interfaces. The skill ensures mocks accurately reflect the API contract without inventing behavior beyond the specification.

When to Use

  • Setting up local development environments
  • Writing contract tests
  • Mocking external APIs for testing
  • Generating API documentation examples

When NOT to Use

  • For production API implementations
  • When a real API is available and accessible
  • For security testing (use specialized tools)

Capabilities

  • OpenAPI/Swagger schema parsing
  • JSON Schema to mock conversion
  • Request/response example generation
  • Contract test skeleton generation
  • Mock server configuration
  • Multi-format support (REST, GraphQL)
  • Header and authentication simulation

Inputs

  • source (required) — OpenAPI file, JSON Schema, or HAR file
  • format (optional) — mock-server, contract-tests, examples
  • framework (optional) — jest, pytest, etc.
  • base_url (optional) — for mock server

Workflow

  1. Parse — Load and analyze schema
  2. Generate — Create mocks from definitions
  3. Validate — Ensure mocks match schema
  4. Package — Generate config files and tests
  5. Document — Provide usage instructions

Tools

  • OpenAPI parsers
  • Mock server tools (Prism, Prism, Mockoon)
  • Test framework integration

Examples

User: "Generate mocks from this OpenAPI spec" Response:

Parsing openapi.yaml...
Found 15 endpoints, 45 schemas

Generated:
- mock-server.js (Prism mock server)
- contracts.test.js (Jest contract tests)
- examples.json (request/response examples)

Run: npx prism mock openapi.yaml

Safety

  • Never mock sensitive data
  • Clearly label generated code as mocks
  • Don't use mocks in place of real integration tests
  • Validate mocks against schema

Source

Auto-generated from openclawskills.net description.

Pairs Well With

  • testing (integration with test suite)
  • frontend-design (frontend API development)
  • db-inspector (backend data structures)

04 同仓库更多 Skills