OpenAPI Import
Mockzilla can ingest any OpenAPI 3.x specification (YAML or JSON) and automatically generate a complete mocked backend. It's designed for Contract-First development, allowing front-end teams to start building before the actual API is ready.
Feature Overview
When you import a specification, Mockzilla automatically configures your environment:
- Automatic Folder Creation: Uses the spec title to group your mocks. Re-importing updates existing routes, keeping your environment in sync with the latest contract.
- Smart Path Mapping: Converts standard OpenAPI parameters (e.g.,
/users/{id}) into functional Wildcards (/users/*) immediately, and uses static nested prefixes as mock subfolders. - High-Fidelity Data: Automatically generates realistic JSON payloads using your defined schemas, formats, and
x-fakerextensions. - Write Method Support: Methods like
POST,PUT, andPATCHare configured to echo the request body by default if no response schema is provided.
Transformation Logic
| OpenAPI Feature | Mockzilla Implementation |
|---|---|
| Nested Paths | Static prefixes become dashboard subfolders so imported APIs stay easy to browse |
| Path Parameters | {id} → * (Wildcard match) |
| JSON Schema | Pre-generated realistic body + Dynamic Schema reference |
| Query Parameters | Default values extracted for match matching |
| Success Responses | Prioritizes 200 or 201 as the default response |
| Metadata | summary or operationId used to name your mocks |
Simple Example
Given this standard OpenAPI specification:
# openapi.yaml
paths:
/users/{userId}:
get:
summary: Get user profile
parameters:
- name: userId
in: path
required: true
schema: { type: string }
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
id: { type: string, format: uuid }
name: { type: string, x-faker: person.fullName }
email: { type: string, format: email }
Result in Mockzilla:
- Path:
/api/mock/my-app/users/*(Works for any ID) - Method:
GET - Generated Body:
{ "id": "550e8400-e29b-41d4-a716-446655440000", "name": "John Doe", "email": "john.doe@example.com" }
Product Dev Focus
- Parallel Development: Front-end developers can build entire features against the "future" API contract.
- Realistic Data: Use
x-fakerto ensure your UI handles real-world data constraints (emails, long names, dates) instead of static placeholders. - Zero Configuration: No manual setup for parameters or status codes. Import and start coding.
Pro Tip: Combine OpenAPI import with the Chrome Extension to intercept real calls and redirect them to your newly created mocks.
