← Back to all products

Mock Server Builder

$9

Create mock API servers from OpenAPI specs for testing and development.

📁 9 files
JSONMarkdownPython

📄 Product Preview

Try the interactive reader and demo tools below, or get the full product with all content unlocked.

📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample

📁 File Structure 9 files

mock-server-builder/ ├── LICENSE ├── README.md ├── examples/ │ └── sample_spec.json ├── free-sample.zip ├── guide/ │ ├── 01_mock-server-builder.md │ ├── 02_features.md │ └── 03_quick-start.md ├── index.html └── src/ └── main.py

📖 Documentation Preview README excerpt

Mock Server Builder

Create mock API servers from OpenAPI specs for testing and development. Zero dependencies.

Part of the API Launchpad toolkit by [CodeVault](https://codevault.dev).

Features

  • OpenAPI 3.0 parsing: reads JSON spec files and creates mock endpoints
  • Fake data generation: realistic data from schema definitions and field names
  • Path parameter matching: /users/{user_id} → captures user_id from URL
  • Hot-reload: edit your spec file, the server picks up changes automatically
  • Endpoint index: GET / lists all available mock endpoints
  • Spec serving: GET /openapi.json returns the loaded spec
  • CORS enabled by default for frontend integration
  • Zero dependencies — runs on Python stdlib only

Quick Start


# Start with built-in demo spec
python3 src/main.py --demo

# Start from your own OpenAPI spec
python3 src/main.py --spec openapi.json

# Custom port
python3 src/main.py --spec openapi.json --port 3000

Then test the mock endpoints:


# List all mock endpoints
curl http://localhost:8080/

# Hit a mock endpoint
curl http://localhost:8080/users
curl http://localhost:8080/users/abc123

How It Works

1. Parse: Reads your OpenAPI spec and extracts all path/method combinations

2. Generate: For each endpoint, creates mock response data from the schema

3. Serve: Starts an HTTP server that matches requests to mock endpoints

4. Reload: Watches the spec file for changes and reloads automatically

Fake Data Generation

The mock server generates realistic data based on field names and schema types:

Field Name ContainsGenerated Value
emailalice@example.com
nameAlice Johnson
url, linkhttps://example.com
company, orgAcme Corp
ida1b2c3d4e5f6 (hash-based)
price, amount42.99 (random float)

... continues with setup instructions, usage examples, and more.

📄 Code Sample .py preview

src/main.py #!/usr/bin/env python3 """ Mock Server Builder — Create Mock APIs from OpenAPI Specs ========================================================== Reads an OpenAPI 3.0 spec (JSON) and spins up a mock HTTP server that returns example responses. Supports path parameters, request validation, fake data generation, and hot-reload of spec changes. Zero dependencies. Run as CLI. Part of the API Launchpad toolkit by DataNest. License: MIT """ from __future__ import annotations import hashlib import json import logging import os import random import re import string import time from dataclasses import dataclass from http.server import HTTPServer, BaseHTTPRequestHandler from pathlib import Path from typing import Any # --------------------------------------------------------------------------- # Configuration # --------------------------------------------------------------------------- DEFAULT_HOST = "0.0.0.0" DEFAULT_PORT = 8080 logging.basicConfig( level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s", datefmt="%Y-%m-%dT%H:%M:%S", ) logger = logging.getLogger("mock-server") # Seed for reproducible fake data random.seed(42) # --------------------------------------------------------------------------- # Fake Data Generator — Generates realistic data from JSON Schema types # ... 400 more lines ...
Buy Now — $9 Back to Products