Skip to content

The digital twin of your backend. Instant OpenAPI mock server with smart data generation, hot reload, and visual dashboard.

Notifications You must be signed in to change notification settings

sametuca/doppelapi

Repository files navigation

DoppelAPI

The digital twin of your backend.

DoppelAPI is a powerful CLI tool that instantly converts your OpenAPI (Swagger) definition into a fully functional, intelligent mock server.

It is designed to solve the age-old problem in software development: Frontend developers waiting for backend APIs to be implemented.

With DoppelAPI, you create a "Digital Twin" of your future backend. It reads your API contract (OpenAPI file) and spawns a server that behaves exactly like the real thing—populating responses with realistic, smart data automatically.

DoppelAPI Dashboard Overview

Why DoppelAPI?

  • Unblock Frontend Teams: Start building UI components immediately using the agreed-upon API contract. No more "mocking hardcoded JSONs" in your codebase.
  • Smart & Realistic Data: Instead of returning string or null, DoppelAPI uses AI-driven Faker.js integration to return real names, emails, addresses, and images based on your schema.
  • Test Edge Cases: Simulate slow networks (latency) or server crashes (chaos mode) with a single flag to ensure your app handles errors gracefully.
  • Self-Documenting: Includes a beautiful Visual Dashboard that serves as live documentation for your team, complete with copy-pasteable request/response examples.

Intelligent Responses

DoppelAPI doesn't just serve static files. It understands your OpenAPI schema and generates data on the fly.

  • Dynamic Data: Every request returns fresh, varied data. It feels like a real database.
  • Schema Compliant: If your schema defines a field as a UUID or an email, DoppelAPI ensures the response matches perfectly.
  • Zero Config: No need to write manual mock scripts. It works straight out of the box with your existing definition file.

DoppelAPI Response Preview

Effortless Requests

Knowing what to send to an API is half the battle. DoppelAPI removes the guesswork.

  • Visual Examples: The built-in Dashboard displays precise JSON Request Bodies for every endpoint. Just copy and paste into your app.
  • Postman Ready: Export the entire API collection to Postman in one click, pre-configured with variable URLs and paths.
  • CORS Solved: Forget about CORS errors during development. DoppelAPI handles headers automatically, so your frontend calls just work.

DoppelAPI Dashboard Preview

Features

  • Instant Mock Server: Turn any valid OpenAPI 3.0+ file (YAML or JSON) into a running server instantly.
  • Smart Data Generation: Uses json-schema-faker and @faker-js/faker to generate realistic data.
    • Supports x-faker schema extensions for precise control (e.g. usernames, emails, avatars).
  • Visual Dashboard: A beautiful web interface to view endpoints, request/response examples and documentation.
  • Postman Export: One-click export of your mock API as a Postman Collection.
  • Hot Reload: Automatically watches your OpenAPI file and restarts the server on changes.
  • Network Simulation: Simulate network latency (500-1500ms) to test loading states.
  • Chaos Mode: Simulate server instability with random 500 errors (10% chance) to test error handling.
  • CORS Enabled: Automatically handles CORS headers, allowing access from any frontend application.
  • Docker Support: Run explicitly in a containerized environment for consistent testing.
  • Interactive CLI: User-friendly wizard to auto-discover files and configure options.

Installation

npm install -g doppelapi

Usage

Quick Start (Interactive Mode)

Simply run the command without arguments to launch the wizard:

doppelapi

The interactive menu will auto-discover OpenAPI files in your directory, or let you provide a custom path:

? Select an OpenAPI file (or choose custom path):
  > openapi.yaml
    ecommerce.json
    Enter custom path manually...

Command Line Arguments

# Basic usage
doppelapi start ./openapi.yaml --port 3000

# Basic usage with custom port
doppelapi start /Users/sametuca/Desktop/example.json --port 8080
doppelapi start /Users/sametuca/Desktop/example.yaml --port 8080

# Enable Hot Reload
doppelapi start ./openapi.yaml --watch

# Enable Network Latency Simulation
doppelapi start ./openapi.yaml --delay

# Enable Chaos Mode (Random 500 Errors)
doppelapi start ./openapi.yaml --chaos

# Combine flags
doppelapi start ./ecommerce.json --watch --delay --chaos

Docker Usage

You can run DoppelAPI as a Docker container:

docker build -t doppelapi .
docker run -p 3000:3000 -v $(pwd)/openapi.yaml:/app/openapi.yaml doppelapi start /app/openapi.yaml

Configuration

Smart Data with x-faker

You can control the generated data by adding x-faker properties to your OpenAPI schema:

User:
  type: object
  properties:
    id:
      type: string
      format: uuid
      x-faker: "string.uuid"
    email:
      type: string
      x-faker: "internet.email"
    avatar:
      type: string
      x-faker: "image.avatar"

Development

  1. Clone the repository
    git clone https://github.com/sametuca/doppelapi
  2. Install dependencies
    npm install
  3. Run in development mode
    npm run dev

License

MIT

About

The digital twin of your backend. Instant OpenAPI mock server with smart data generation, hot reload, and visual dashboard.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published