A general-purpose mock API server built for quick prototyping, testing, and simulating HTTP endpoints.
- 🔧 Dynamically add mock API endpoints at runtime
- 🧪 Supports all HTTP methods
- 📝 JSON request & response support
- 🚀 Fast and lightweight, ideal for local testing and CI
Ensure JRE/JDK 21+ has been pre-installed on your machine.
api-simulators/packages/generic-api-simulator$ mvn spring-boot:run
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.4.5)
GenericApiSimulatorApplication : Started GenericApiSimulatorApplication in 0.809 seconds (process running for 0.963)
api-simulators/packages/generic-api-simulator/target$ java -jar generic-api-simulator-0.0.1-SNAPSHOT.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.4.5)
2025-05-24T16:50:51.266+12:00 INFO 44356 --- [generic-api-simulator] [ main] c.d.s.g.GenericApiSimulatorApplication : Starting GenericApiSimulatorApplication v0.0.1-SNAPSHOT using Java 21.0.3 with PID 44356 (/Users/t827056/personal-workspace/api-simulators/packages/generic-api-simulator/target/generic-api-simulator-0.0.1-SNAPSHOT.jar started by t827056 in /Users/t827056/personal-workspace/api-simulators/packages/generic-api-simulator/target)
2025-05-24T16:50:51.267+12:00 INFO 44356 --- [generic-api-simulator] [ main] c.d.s.g.GenericApiSimulatorApplication : No active profile set, falling back to 1 default profile: "default"
2025-05-24T16:50:51.758+12:00 INFO 44356 --- [generic-api-simulator] [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port 8080 (http)
2025-05-24T16:50:51.764+12:00 INFO 44356 --- [generic-api-simulator] [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2025-05-24T16:50:51.764+12:00 INFO 44356 --- [generic-api-simulator] [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.40]
2025-05-24T16:50:51.777+12:00 INFO 44356 --- [generic-api-simulator] [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2025-05-24T16:50:51.777+12:00 INFO 44356 --- [generic-api-simulator] [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 484 ms
2025-05-24T16:50:52.031+12:00 INFO 44356 --- [generic-api-simulator] [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint beneath base path '/actuator'
2025-05-24T16:50:52.063+12:00 INFO 44356 --- [generic-api-simulator] [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'
2025-05-24T16:50:52.075+12:00 INFO 44356 --- [generic-api-simulator] [ main] c.d.s.g.GenericApiSimulatorApplication : Started GenericApiSimulatorApplication in 1.008 seconds (process running for 1.277)
# Step 1: Build docker image (locally) via Google Jib plugin. (Ensure your docker daemon is up and running)
api-simulators/packages/generic-api-simulator$ mvn compile jib:dockerBuild
[INFO] Built image to Docker daemon as akldamonx/api-simulator
[INFO] Executing tasks:
[INFO] [==============================] 100.0% complete
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.375 s
[INFO] Finished at: 2025-05-25T20:21:42+12:00
[INFO] ------------------------------------------------------------------------
# Step 2: Add Docker Image into docker container and run
curl -X POST http://localhost:8080/simulator-admin/addmock \
-H 'Content-Type: application/json' \
-d '{
"path": "/api/hello",
"method": "GET",
"responseBody": "{\"msg\":\"Hello, world!\"}",
"statusCode": 200
}'mock.json
{
"path": "/api/hello",
"method": "GET",
"responseBody": "{\"msg\":\"Hello, world!\"}",
"statusCode": 200
}
curl -X POST http://localhost:8080/simulator-admin/addmock \
-H 'Content-Type: application/json' \
-d @mock.json
curl http://localhost:8080/api/hello
{
"msg": "Hello, world!"
}