Dynamic mock API generator
186
Dynamic mock API generator — define REST services from JSON schemas, generate fake data, and manage records through a Blazor admin UI. One container includes Admin + API + Swagger.
Built with ASP.NET Core 10, PostgreSQL (JSONB), and MudBlazor.
| Component | Path |
|---|---|
| Admin panel | http://localhost:5014/ |
| REST API | http://localhost:5014/api/... |
| Swagger UI | http://localhost:5014/swagger |
| Health check | http://localhost:5014/health |
This image does not include PostgreSQL. You need a separate Postgres instance.
docker pull mortenahohub/mockforge:latest
docker run -d --name mockforge-postgres \
-e POSTGRES_DB=mockforge \
-e POSTGRES_USER=mori \
-e POSTGRES_PASSWORD=1662 \
-p 5433:5432 \
postgres:16-alpine
docker run -d --name mockforge \
-p 5014:8080 \
-e ConnectionStrings__Default="Host=host.docker.internal;Port=5433;Database=mockforge;Username=mori;Password=1662" \
mortenahohub/mockforge:latest
Linux: replace host.docker.internal with your Postgres host IP or use a shared Docker network.
Clone the repository and run:
docker compose up -d
This starts Postgres + MockForge together with the correct connection string.
| Variable | Default | Description |
|---|---|---|
ConnectionStrings__Default | — | Required. PostgreSQL connection string |
Backend__Mode | Direct | In-process backend (single-container mode) |
Backend__ExposeApi | true | Expose REST API on the same port as Admin |
Backend__EnableSwagger | true | Enable Swagger UI at /swagger |
ASPNETCORE_URLS | http://+:8080 | Listen address inside the container |
GET /api/services/{id}/openapi.json/api/users)/api/users/1277/api/users/96ff0065-2ac7-4186-aa67-f11cf7b4d2aaid, userid, *id suffix, or explicit primaryKeyField?search=john&page=1&pageSize=10address.city)sortBy / sortDir query params{ responsecode, responsemessage, data } with configurable keyspage, totalCount, hasNextPage, etc.{ "data": { ... } } or flat JSONReturn a fake answer instead of normal CRUD when a condition matches — useful for testing 404, 403, etc. in your frontend.
Two ways to match:
| Match type | Example | When it runs |
|---|---|---|
| URL key | UrlKeyEquals = 0 | GET /api/users/0 → your custom 404 |
| Field value | Field = userid, Equals = 999 | Body (POST/PUT) or loaded record (GET item) |
Applies to: GET /{id}, POST, PUT, PATCH — not list (GET collection) or DELETE.
Example rule: if URL ends with 0, return 404:
{
"urlKeyEquals": "0",
"statusCode": 404,
"body": { "message": "User not found" }
}
Configure rules in Edit service → Schema Builder → Conditional responses.
# Health
curl http://localhost:5014/health
# Create a service
curl -X POST http://localhost:5014/api/services \
-H "Content-Type: application/json" \
-d '{
"name": "Users",
"route": "/api/users",
"schemaDefinition": {
"primaryKeyField": "userid",
"fields": [
{ "name": "userid", "type": "Int", "required": true, "unique": true, "searchable": true },
{ "name": "fullname", "type": "String", "searchable": true },
{ "name": "email", "type": "Email", "required": true, "unique": true }
],
"response": { "style": "Envelope" },
"query": { "enableSearch": true, "enablePagination": true }
}
}'
# Export / import service definition
curl http://localhost:5014/api/services/{id}/export
curl -X POST http://localhost:5014/api/services/import -H "Content-Type: application/json" -d @service.json
# Per-service OpenAPI
curl http://localhost:5014/api/services/{id}/openapi.json
# Seed fake data
curl -X POST "http://localhost:5014/api/services/{id}/seed?count=10"
# List with search + pagination (nested fields searched automatically)
curl "http://localhost:5014/api/users?search=john&page=1&pageSize=10"
# Get / update / patch / delete one record
curl http://localhost:5014/api/users/1277
curl -X PUT http://localhost:5014/api/users/1277 -H "Content-Type: application/json" -d '{"userid":1277,"fullname":"Jane"}'
curl -X PATCH http://localhost:5014/api/users/1277 -H "Content-Type: application/json" -d '{"fullname":"Jane Doe"}'
curl -X DELETE http://localhost:5014/api/users/1277
Map container port 8080 to any host port:
docker run -p 5014:8080 ... # Admin + API on 5014
docker run -p 8080:8080 ... # Admin + API on 8080
There is no separate API port — frontend and backend share one port.
| Tag | Description |
|---|---|
latest | Current stable build |
MockForge — Dynamic Mock API Studio
.NET 10 · PostgreSQL · Blazor Server · MudBlazor
Content type
Image
Digest
sha256:da2435e50…
Size
98.9 MB
Last updated
4 months ago
docker pull mortenahohub/mockforge