Skip to content
Back to skills

Api Mock Server

ASecurity

Spin up mock API servers from OpenAPI/Swagger specs with

  • 21 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 7, 2026
developmentjavascriptjavabashnodeexpresstestingapisecurity

Works with

  • cli
  • api

Security analysis

A96/100
  • mediumUses curl or wget to download content

Pro scans all 2 files and shows the line behind each finding

Scanned September 7, 2026

npx -y skills add modbender/skill-library-mcp --skill api-mock-server --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api Mock Server?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Api Mock Server
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/modbender-api-mock-server/badge)](https://www.skillsdirectory.com/skills/modbender-api-mock-server)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: api-mock-server
description: Spin up mock API servers from OpenAPI/Swagger specs with
  auto-generated test data.
---


# API Mock Server

Instantly create a mock API server from an OpenAPI/Swagger spec.

## Instructions

### Step 1: Get the Spec
Accept from user:
- File path (JSON/YAML)
- URL to a spec
- Inline endpoint definitions → convert to OpenAPI 3.0

If no spec exists, help define endpoints interactively and generate one.

### Step 2: Start the Mock Server
```bash
# Primary: Prism (Stoplight)
npx @stoplight/prism-cli mock <spec-file> --port ${PORT:-4010} --dynamic

# Alternative: json-server for simple REST
npx json-server --watch db.json --port ${PORT:-4010}
```
- `--dynamic` generates realistic fake data from schema constraints
- Default port: 4010

### Step 3: Verify
```bash
# Test a sample endpoint
curl -s http://localhost:4010/api/resource | jq .

# List all routes (Prism logs them on startup)
```

### Fallback: Custom Express Server
If prism is unavailable, generate a minimal Express server:
```javascript
const express = require('express');
const app = express();
app.use(express.json());
// Auto-generate routes from spec...
```

## Edge Cases

- **CORS**: Add `--cors` flag or set `Access-Control-Allow-Origin: *` for browser testing
- **Auth mocking**: Return 401 for endpoints with security schemes when no token provided
- **Large specs**: Prism handles them fine; json-server may need splitting
- **Port conflicts**: Check with `lsof -i :<port>` before starting

## Security

- Mock servers are for **development only** — never expose to public internet
- Don't include real API keys or credentials in mock responses

## Requirements

- Node.js 16+ (for npx)
- No API keys needed

Files in this skill

  • README.md764 B
  • SKILL.md1.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.