CLI tool for generating mock data from OpenAPI definitions for MSW
Top 79.7% on sourcepulse
This CLI tool generates random mock data from OpenAPI definitions for Mock Service Worker (MSW). It automates the creation of response resolvers, saving developers from manual, repetitive coding. The tool supports both Faker.js and generative AI (OpenAI, Azure, Anthropic) for data generation, catering to teams needing efficient API mocking for frontend development and testing.
How It Works
The tool parses OpenAPI specifications (JSON or YAML) to understand API endpoints, request parameters, and response schemas. It then leverages either @faker-js/faker
or configured AI providers to generate realistic mock data that conforms to these schemas. The output is a set of MSW request handlers, ready to be integrated into an application's service worker for intercepting network requests. The AI integration allows for more contextually relevant and potentially complex mock data generation.
Quick Start & Requirements
yarn add msw-auto-mock @faker-js/faker -D
npx msw-auto-mock <http_url_or_file_path> -o ./mock
@faker-js/faker >= 8
, msw >= 2
.OPENAI_API_KEY
).Highlighted Details
Maintenance & Community
The project appears to be actively maintained by a single author, zoubingwu. There are no explicit links to community channels like Discord or Slack provided in the README.
Licensing & Compatibility
The README does not explicitly state a license. However, the dependencies (@faker-js/faker
and msw
) are typically MIT licensed, suggesting potential MIT compatibility. Commercial use would require explicit license confirmation.
Limitations & Caveats
The AI integration requires careful configuration of API keys and environment variables, with potential costs associated with AI API usage. The README does not detail performance benchmarks or specific limitations regarding the complexity of OpenAPI schemas it can handle.
3 months ago
Inactive