API Mock Generator
CLI tool that generates mock API responses from OpenAPI specs for testing.
Why I Built This
Tech Stack
Technical Approach
Built a CLI tool in Dart that parses OpenAPI specs and generates a mock server with realistic fake data.
OpenAPI Parser
Built a robust parser for OpenAPI 3.0 specs supporting all common schema types.
Data Generation
Integrated Faker library with smart type inference for realistic data.
Mock Server
Created a lightweight HTTP server that serves generated responses with configurable latency.
CLI Interface
Designed intuitive CLI with watch mode for spec changes.
Key Learnings
What worked, what didn't, and what I'd do differently.
What Worked
- Type inference from property names creates realistic data
- Cached responses improve consistency during testing
- Watch mode speeds up iterative development
Challenges Faced
- Complex $ref resolution had edge cases that needed handling
- Some OpenAPI extensions weren't widely documented
Key Insights
The bigger lessons that go beyond this specific experiment.
Specs Are Contracts
Good OpenAPI specs benefit both frontend and backend teams equally.
Realistic Data Matters
Edge cases in data (empty arrays, long strings) catch UI bugs early.
CLI UX
Good CLI tools have sensible defaults but allow customization.