A MuleSoft API implementation that demonstrates MySQL database integration using Docker containers. This project shows how to build a Todo API with database connectivity in Anypoint Code Builder (ACB).
The complete OpenAPI 3.0 specification is available in todo-task-api.yaml
. This project currently references an API specification from a specific organization. To use this project:
- Import the specification - Upload
todo-task-api.yaml
to your Anypoint Exchange - Update the reference - Modify the API reference in
src/main/mule/global.xml
andpom.xml
to point to your organization's API - Configure the project - Update the
api
attribute in theapikit:config
element with your organization's API details
The API specification defines:
- All available endpoints and their operations
- Request/response schemas for Task objects
- Query parameters for filtering tasks
- Error responses and status codes
- ✅ MySQL database running in Docker
- ✅ MuleSoft flows with database operations
- ✅ DataWeave transformations for SQL and JSON
- ✅ RESTful API endpoints
- ✅ VS Code integration with Container Tools and Database Client
- ✅ OpenAPI 3.0 specification
Method | Endpoint | Status | Description |
---|---|---|---|
GET | /api/tasks |
✅ Implemented | Get all tasks |
GET | /api/tasks/{taskId} |
🔄 Placeholder | Get specific task |
POST | /api/tasks |
🔄 Placeholder | Create new task |
PUT | /api/tasks/{taskId} |
🔄 Placeholder | Update task |
DELETE | /api/tasks/{taskId} |
🔄 Placeholder | Delete task |
- VS Code with extensions:
- Docker Desktop
Use the Container Tools extension in VS Code to click "Run All Services" on the docker-compose.yml
file.
version: '3'
services:
db:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: admin
MYSQL_DATABASE: mysqldb
MYSQL_USER: user
MYSQL_PASSWORD: password
ports:
- 3306:3306
volumes:
- db_data:/var/lib/mysql
volumes:
db_data:
Connect to MySQL using the Database Client extension:
- Host:
127.0.0.1
- Port:
3306
- User:
user
- Password:
password
- Database:
mysqldb
Run the SQL script to create the tasks table:
CREATE TABLE tasks(
id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
description VARCHAR(255),
dueDate VARCHAR(255),
completed BOOLEAN NOT NULL
);
Start the Mule application in Anypoint Code Builder.
Use Postcode or any REST client:
GET http://localhost:8081/api/tasks