Mockzilla logo

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 minItems and maxItems to 0 on an array.

Comparative Table

FeatureStatic ResponseDynamic Response
Setup TimeInstant (Copy/Paste)Minutes (Write Schema)
Realistic DataFixed values or templatesGenerated from schema and optional Faker fields
MaintenanceManual (Edit every time)Automatic (Update schema)
PerformanceMaximum (Zero processing)High (Small generation overhead)
Edge Case CoverageExplicit examplesDepends on schema constraints and generators
Skill RequiredBasic JSON knowledgeJSON 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 properties is generated, even if it is not listed in required.
  • 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.