Static vs. Dynamic Mocks
Mockzilla offers two ways to define the data your API returns: Static Response and Dynamic Response (via JSON Schema).
1. Static Responses
A Manual JSON response uses the body you provide. Templates in that body can still interpolate request values and use helpers, so a manual response is not necessarily identical on every request.
Best for:
- Quick Prototyping: You just need any data to show in a UI component.
- Fixed Values: Endpoints that rarely change (e.g., a "Privacy Policy" URL).
- One-off Testing: Simulating a specific, static error code (e.g., a 403 Forbidden).
2. Dynamic Responses
A Dynamic Response uses a JSON Schema and Faker.js to generate fresh, varied data on every request.
Best for:
- Massive Datasets: Testing lists of 100+ items without manually writing the JSON.
- Realistic UI Testing: Seeing how your UI handles long vs. short strings, different names, and various dates.
- Empty States: Testing the "No data found" scenario by setting
minItemsandmaxItemsto0on an array.
Comparative Table
| Feature | Static Response | Dynamic Response |
|---|---|---|
| Setup Time | Instant (Copy/Paste) | Minutes (Write Schema) |
| Realistic Data | Fixed values or templates | Generated from schema and optional Faker fields |
| Maintenance | Manual (Edit every time) | Automatic (Update schema) |
| Performance | Maximum (Zero processing) | High (Small generation overhead) |
| Edge Case Coverage | Explicit examples | Depends on schema constraints and generators |
| Skill Required | Basic JSON knowledge | JSON Schema + Faker awareness |
The "Clean Generation" Rule
By default, Mockzilla only generates the fields you explicitly define in your properties block. This ensures your API responses are clean and match your documentation exactly, without auto-generated "garbage" fields.
- Explicit Properties: Only keys defined in the schema are included.
- Optional fields included: Every property in
propertiesis generated, even if it is not listed inrequired. - Explicit schemas: Define the properties you want and test the generated output, especially when using composition or
additionalProperties.
Next Step: Learn how to write these schemas in the JSON Schema Reference, then try the Infinite Scroll Guide.
