Mockery is a lightweight and dynamic mock API server built with Spring Boot.
It allows developers to register and simulate custom HTTP endpoints at runtime — ideal for frontend development, API prototyping, and contract testing.
- ✅ Create mock endpoints via REST API
- 🛠️ Support for dynamic method + path (e.g.
/users/:id) - 💾 In-memory storage for mock configuration (can be extended to DB)
- 📦 Simple JSON-based request/response definitions
- 🔍 Match any path using basic
:paramsupport
- Frontend devs testing without waiting for real backend
- QA mocking edge cases or API contracts
- Quick API prototyping with no database
./mvnw spring-boot:runTo register a new mock endpoint dynamically, send a POST request to /__mock with a JSON body that defines:
- HTTP method
- Path (can include
:params) - Response status and body
curl -X POST http://localhost:8080/__mock \
-H "Content-Type: application/json" \
-d '{
"method": "GET",
"path": "/hello",
"response": {
"status": 200,
"body": {
"message": "Hello, World!"
}
}
}'Once registered, the endpoint becomes immediately available without restarting the server:
curl http://localhost:8080/helloExpected Output
{
"message": "Hello, World!"
}curl -X POST http://localhost:8080/__mock \
-H "Content-Type: application/json" \
-d '{
"method": "GET",
"path": "/users/:id",
"response": {
"status": 200,
"body": {
"id": 42,
"role": "admin"
}
}
}'curl http://localhost:8080/users/42Expected Output
{
"id": 42,
"role": "admin"
}