@trillionclues/contour
v1.1.1
Published
Professional API mock server from OpenAPI specifications
Maintainers
Readme
Install
npm install -g @trillionclues/contour
# or
pnpm add -g @trillionclues/contour
# or
npx @trillionclues/contour start openapi.yamlRequires Node.js >= 18
Usage
contour start ./api/openapi.yaml # local file
contour start https://example-openapi.com/api.json # remote URL
contour start curl -s http://127.0.0.1:3001/pet/findByStatus?status=pending | jq '.' # Swagger UI pageYour mock API is running at http://localhost:3001 with realistic, type-safe responses.
Sample Remote URL
https://petstore.swagger.io/v2/swagger.json (JSON format)
https://petstore.swagger.io/v2/swagger.yaml (YAML format)Options
contour start <spec> [options]
-p, --port <number> Port (default: 3001)
--stateful Persist POST/PUT/DELETE data in memory
--deterministic Reproducible data for E2E tests
--delay <min-max> Simulate latency, e.g. --delay 200-500
--error-rate <percent> Simulate failures, e.g. --error-rate 10
--require-auth Require Bearer tokenExamples
contour start api.yaml --port 4000 --delay 100-300
contour start api.yaml --deterministic --stateful
contour start api.yaml --error-rate 15 --delay 500-2000Features
- Smart data generation — property-name heuristics produce real names, emails, addresses
- Stateful mode — POST creates, GET retrieves, DELETE removes — full CRUD without a database
- Request validation — validates POST/PUT/PATCH bodies against your schema, returns
400with details x-contour-*extensions — fine-tune per-endpoint behavior directly in your spec:
/users:
get:
x-contour-count: 20 # array size override
x-contour-delay: 1000 # per-route latency (ms)
x-contour-deterministic: true # consistent data per endpoint- Spec caching —
contour cache list/contour cache clear - Offline support — cached specs work without network
Framework Integration
Next.js / React
{
"scripts": {
"dev": "concurrently \"contour start api.yaml\" \"next dev\"",
"test:e2e": "contour start api.yaml --deterministic & playwright test"
}
}Vite
// vite.config.js
export default defineConfig({
server: { proxy: { '/api': 'http://localhost:3001' } }
});Contributing
Contributions are welcome! See CONTRIBUTING.md.
