A comprehensive Spring Boot application that provides a sandbox environment for testing, mocking, and generating complete microservices from OpenAPI/Swagger specifications. It features a deterministic + AI-assisted workflow for rapid API development and deployment.
- API Specification Import: Import OpenAPI/Swagger specs from URLs
- Mock Data Generation: Automatically generate realistic mock responses
- Test Case Generation: AI-powered test case generation for API endpoints
- Validation: Comprehensive request and response validation
- Configurable Sandbox: Adjustable mock data and validation settings
- RESTful API: Full REST API for managing and testing APIs
- Complete Microservice Generation: Transform OpenAPI specs into production-ready Spring Boot microservices
- Database Schema Generation: Automatic entity and table creation with relationships
- Full CRUD Operations: Complete REST APIs with pagination, search, and filtering
- Realistic Test Data: Smart test data generation based on field types and contexts
- Deployment Ready: Docker, Kubernetes, and production configurations
- AI-Assisted Planning: Intelligent test planning and execution strategies
- API Analysis: Intelligent complexity analysis and testing recommendations
- Test Plan Generation: Comprehensive test case creation with priority-based execution
- Execution Planning: Optimized test workflow and scheduling
- Quality Assurance: Automated validation and quality checks
- Java 17 or higher
- Maven 3.6 or higher
- Clone the repository:
git clone <repository-url>
cd agentic-api-sandbox- Build the application:
mvn clean install- Run the application:
mvn spring-boot:runThe application will start on http://localhost:8080/api
Once the application is running, you can access:
- Swagger UI:
http://localhost:8080/api/swagger-ui.html - OpenAPI JSON:
http://localhost:8080/api/api-docs
POST /api/sandbox/import/url?url=<swagger-url>GET /api/sandbox/specsGET /api/sandbox/specs/{id}POST /api/sandbox/execute/{apiSpecId}/{endpointId}?statusCode=200GET /api/sandbox/config
PUT /api/sandbox/configPOST /api/microservice/generate/{apiSpecId}Transform an API specification into a complete Spring Boot microservice.
GET /api/microservice/download/{microserviceId}Download the generated microservice as a ZIP file.
GET /api/microservice/preview/{microserviceId}Preview the generated microservice files before download.
POST /api/microservice/validateValidate if an API specification is suitable for microservice generation.
GET /api/agent/analyze/{apiSpecId}AI-powered analysis of API complexity and testing requirements.
POST /api/agent/test-plan/{apiSpecId}Generate comprehensive test plan with AI assistance.
POST /api/agent/execution-plan/{apiSpecId}Create priority-based test execution strategy.
The application can be configured via application.yml:
agentic:
sandbox:
mock-data:
enabled: true
default-response-delay: 100ms
validation:
strict-mode: false
swagger:
max-file-size: 10MB
supported-versions: [3.0, 3.1]The application follows a layered architecture:
- Controller Layer: REST API endpoints
- Service Layer: Business logic and orchestration
- Model Layer: Data models and entities
- Agent Layer: AI-powered test planning and generation
- Config Layer: Application configuration
- SwaggerParserService: Parses OpenAPI/Swagger specifications
- MockDataService: Generates mock responses based on endpoint definitions
- ValidationService: Validates API specifications and requests
- SandboxOrchestrator: Coordinates all sandbox operations
- MicroserviceGenerator: Orchestrates complete microservice generation
- DatabaseSchemaGenerator: Converts API specs to database schemas
- EntityGenerator: Creates JPA entity classes with relationships
- RepositoryGenerator: Generates Spring Data repository interfaces
- ServiceGenerator: Creates business logic layer with CRUD operations
- ControllerGenerator: Generates REST controllers with OpenAPI documentation
- TestDataGenerator: Creates realistic test data based on field types
- ConfigGenerator: Generates deployment configurations (Docker, Kubernetes)
- ApiSpec: Represents an imported API specification
- Endpoint: Represents an API endpoint with its configuration
- RequestPayload: Defines request payload structure and validation
- MicroserviceSpec: Complete microservice specification
- EntitySpec: Database entity definitions with field specifications
- FieldSpec: Field type, validation, and database mapping
- RelationshipSpec: Entity relationship definitions
- SandboxController: Core sandbox functionality endpoints
- MicroserviceController: Microservice generation endpoints
- AgentController: AI-powered test planning and analysis
- AgentPlanner: Generates comprehensive test plans and execution strategies
curl -X POST "http://localhost:8080/api/sandbox/import/url?url=https://petstore.swagger.io/v2/swagger.json"curl -X POST "http://localhost:8080/api/sandbox/execute/{apiSpecId}/{endpointId}" \
-H "Content-Type: application/json" \
-d '{"name": "Test Pet", "status": "available"}'curl -X PUT "http://localhost:8080/api/sandbox/config" \
-H "Content-Type: application/json" \
-d '{"mockDataEnabled": true, "validationStrictMode": false}'# 1. Import an API specification
curl -X POST "http://localhost:8080/api/sandbox/import/url?url=https://petstore.swagger.io/v2/swagger.json"
# 2. Generate a complete microservice from the imported spec
curl -X POST "http://localhost:8080/api/microservice/generate/{apiSpecId}" \
-H "Content-Type: application/json" \
-d '{
"name": "pet-store-microservice",
"packageName": "com.example.petstore",
"databaseType": "postgresql",
"buildTool": "maven"
}'
# 3. Preview the generated files
curl -X GET "http://localhost:8080/api/microservice/preview/{microserviceId}"
# 4. Download the complete microservice as ZIP
curl -X GET "http://localhost:8080/api/microservice/download/{microserviceId}" \
-o pet-store-microservice.zip# 1. Analyze the API specification
curl -X GET "http://localhost:8080/api/agent/analyze/{apiSpecId}"
# 2. Generate comprehensive test plan
curl -X POST "http://localhost:8080/api/agent/test-plan/{apiSpecId}"
# 3. Create execution plan
curl -X POST "http://localhost:8080/api/agent/execution-plan/{apiSpecId}"The generated microservice includes:
- JPA Entities: Complete with relationships and validation
- Repositories: Spring Data with custom queries
- Database Migrations: Automatic schema generation
- Test Data: Realistic sample data
- Business Logic: Complete CRUD operations
- Validation: Input validation and business rules
- Transaction Management: Proper transaction boundaries
- Error Handling: Comprehensive error management
- OpenAPI Documentation: Complete API documentation
- CRUD Endpoints: Full REST operations
- Pagination & Sorting: Efficient data retrieval
- Search & Filtering: Advanced query capabilities
- Dockerfile: Container configuration
- Kubernetes: Orchestration manifests
- Docker Compose: Local development setup
- Environment Configs: Multiple environment support
src/main/java/com/agentic/sandbox/
βββ controller/
β βββ SandboxController.java
βββ service/
β βββ SwaggerParserService.java
β βββ MockDataService.java
β βββ ValidationService.java
β βββ SandboxOrchestrator.java
βββ model/
β βββ ApiSpec.java
β βββ Endpoint.java
β βββ RequestPayload.java
βββ agent/
β βββ AgentPlanner.java
βββ config/
βββ AppConfig.java
- Add new models in the
modelpackage - Implement business logic in the
servicepackage - Expose functionality through the
controllerpackage - Add configuration in the
configpackage
Run the tests with:
mvn test- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License.