Mock 数据生成

Generate JSON mock data files from API definitions and TypeScript types.

4|2|Updated Feb 13, 2023
One-click install
npx skills add https://github.com/bianliuzhu/an-cli --skill mock-bianliuzhu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Mock 数据生成
Source: https://github.com/bianliuzhu/an-cli/tree/main/postbuild-assets/skills/api-mock
Command: npx skills add https://github.com/bianliuzhu/an-cli --skill mock-bianliuzhu

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill automates the creation of mock data files for API endpoints, ensuring your frontend development can proceed even before backend APIs are fully implemented.

Core Features & Use Cases

  • Automated Mock Generation: Creates .json mock files based on API definitions and associated TypeScript types.
  • Realistic Data: Employs MockJS syntax to generate data that closely resembles real-world values for various data types and structures.
  • Use Case: When developing a new feature that relies on an API endpoint like /api/forward/op/trade/order/queryPage, this Skill can generate a order-query-page.json file with realistic sample data for testing the UI.

Quick Start

Use the api-mock skill to generate mock data for all API definitions found in the {{API_DIR}} directory.

Frequently Asked Questions about Mock 数据生成

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate mock data for frontend testing when the backend API is not ready?

To generate mock data for frontend testing, this Skill parses API function signatures and TypeScript type structures to produce JSON files with realistic data. It enables frontend development to proceed independently by providing accurate mock responses using MockJS syntax.

Can I generate mock JSON files from TypeScript type definitions and API signatures?

Yes, you can generate mock JSON files from TypeScript types. The Skill traces type definitions and parses API function signatures to create accurate mock responses, automatically handling enums, pagination, and various data types using MockJS syntax.

What is the best way to mock API pagination and enum data for frontend development?

The best way to mock API pagination and enum data is using this Skill's automated generation, which parses TypeScript types and applies MockJS syntax to output JSON files. It specifically handles pagination structures and enum values to ensure realistic sample data for UI testing.

How do I batch generate mock data files for an entire API directory?

To batch generate mock data files, point the Skill at your API directory. It will scan all API definitions found within, parse the associated TypeScript types, and output individual JSON mock files with realistic data for each endpoint to support your frontend testing workflow.

Does this mock data generator work without external dependencies?

Yes, this mock data generator works without external dependencies. It operates directly on your API definitions and TypeScript type structures, using MockJS syntax internally to produce standalone JSON files that require no additional runtime libraries to function.