api-bridge-mcp-server

APIBridge Test Suite Documentation

This directory contains comprehensive test cases and sample APIs to validate the APIBridge MCP server’s workflow generation capabilities. The test suite demonstrates how APIBridge handles different API patterns, domains, and complexities.

Test Files Overview

1. Core Test Suite

2. Sample API Specifications

../demo-api/sample-api.yml - Original Demo API

sample-ecommerce-api.yml - E-commerce Management API

sample-library-api.yml - Library Management System

sample-healthcare-api.yml - Healthcare Management API

Running Tests

1. Full Test Suite

Runs all internal tests with the demo API:

node test/workflow-generator.test.js

What it tests:

2. Individual API Testing

Test any specific OpenAPI specification:

# Test e-commerce API
node test/workflow-generator.test.js test/sample-ecommerce-api.yml

# Test library API
node test/workflow-generator.test.js test/sample-library-api.yml

# Test healthcare API
node test/workflow-generator.test.js test/sample-healthcare-api.yml

# Test your own API
node test/workflow-generator.test.js path/to/your-api.yml

3. Batch Testing

Test all sample APIs at once:

echo "=== Testing E-commerce API ===" && \
node test/workflow-generator.test.js test/sample-ecommerce-api.yml && \
echo -e "\n=== Testing Library API ===" && \
node test/workflow-generator.test.js test/sample-library-api.yml && \
echo -e "\n=== Testing Healthcare API ===" && \
node test/workflow-generator.test.js test/sample-healthcare-api.yml && \
echo -e "\n=== Testing Original Demo API ===" && \
node test/workflow-generator.test.js demo-api/sample-api.yml

Test Coverage

API Patterns Covered

  1. Simple CRUD Operations
    • Basic Create, Read, Update, Delete
    • Path parameters and query parameters
    • Request/response body validation
  2. Foreign Key Relationships
    • authorIdusers (Posts to Users)
    • patientIdpatients (Appointments to Patients)
    • customerIdcustomers (Orders to Customers)
    • bookId + borrowerId (Loans with multiple dependencies)
  3. Schema Patterns
    • $ref references and schema reuse
    • allOf inheritance patterns
    • Nested object schemas
    • Array schemas with typed items
  4. Data Types and Formats
    • UUID identifiers
    • Date/time fields
    • Email and URI formats
    • Enumerated values
    • Numeric fields with constraints
  5. HTTP Methods
    • GET (list and individual)
    • POST (create)
    • PUT (full update)
    • PATCH (partial update)
    • DELETE (remove)
  6. Industry-Specific Patterns
    • E-commerce: Inventory, payments, orders
    • Healthcare: Patient records, appointments, medical data
    • Library: Book lending, member management
    • General: User management, content publishing

Error Scenarios Tested

  1. File System Errors
    • Non-existent files
    • Unsupported file formats
    • Permission issues
  2. YAML/JSON Parsing Errors
    • Malformed YAML syntax
    • Invalid JSON structure
    • Encoding issues
  3. OpenAPI Specification Errors
    • Missing required fields
    • Invalid schema references
    • Broken $ref links
  4. Schema Validation Errors
    • Invalid JSON Schema formats
    • Type mismatches
    • Missing required properties

Extending the Test Suite

Adding New Test APIs

  1. Create your API specification:
    # Create in test/ directory
    touch test/sample-your-domain-api.yml
    
  2. Follow naming conventions:
    • Use sample-{domain}-api.yml format
    • Include comprehensive CRUD operations
    • Add foreign key relationships for testing
  3. Test your API:
    node test/workflow-generator.test.js test/sample-your-domain-api.yml
    

Adding New Test Cases

  1. Edit workflow-generator.test.js
  2. Add new test functions:
    async function testYourNewFeature() {
      console.log('\n🧪 Running Test Suite X: Your New Feature...');
      // Your test logic here
    }
    
  3. Call from main function:
    await testYourNewFeature();
    

Best Practices for API Testing

1. Comprehensive Coverage

2. Real-World Patterns

3. Foreign Key Testing

4. Schema Validation

Expected Output

Successful Test Run

🔍 Validating user-provided OpenAPI file: test/sample-library-api.yml

🧪 Running Test Suite 1: Core Workflow Generation for test/sample-library-api.yml...
==================================================================

📊 API Parsing and Initial Setup:
✅ Successfully parsed OpenAPI specification and found endpoints.
✅ Successfully generated workflows.
✅ Found at least one endpoint.
✅ Generated at least one workflow.

🔍 Analyzing 'books_crud_workflow':
✅ Workflow 'books_crud_workflow' should have at least one step.
✅ CREATE step in 'books_crud_workflow' should have a 'data' object.

🔍 Analyzing 'authors_crud_workflow':
✅ Workflow 'authors_crud_workflow' should have at least one step.
✅ CREATE step in 'authors_crud_workflow' should have a 'data' object.

🔍 Analyzing 'borrowers_crud_workflow':
✅ Workflow 'borrowers_crud_workflow' should have at least one step.
✅ CREATE step in 'borrowers_crud_workflow' should have a 'data' object.

🎉🎉 OpenAPI specification appears to be valid and workflows were generated successfully! 🎉🎉

Failed Test Run

❌ VALIDATION FAILED: Failed to parse OpenAPI spec: No paths found in OpenAPI specification

Using Tests for Development

1. Validate Your API Design

Use the test suite to validate your OpenAPI specifications before implementation.

2. Test Workflow Generation

Ensure APIBridge can generate appropriate workflows for your API patterns.

3. Debug Issues

Use verbose output to understand how APIBridge processes your API:

node index.js your-api.yml --verbose

4. Baseline Testing

Use the sample APIs as baselines to understand expected patterns and structures.

Support and Troubleshooting

Common Issues

  1. No workflows generated
    • Check that your API has proper CRUD endpoints
    • Ensure paths follow REST conventions
    • Verify schema references are valid
  2. Foreign key detection fails
    • Use {resource}Id naming convention
    • Ensure referenced resources have CRUD endpoints
    • Check that schemas are properly defined
  3. Schema validation errors
    • Validate your OpenAPI spec with online tools
    • Check for proper $ref syntax
    • Ensure all required fields are defined

Getting Help

  1. Run the full test suite to ensure base functionality works
  2. Test with sample APIs to understand expected patterns
  3. Use verbose logging to debug specific issues
  4. Check the logs directory for detailed error information

Summary

The APIBridge test suite provides comprehensive validation for:

This ensures that APIBridge’s foundation-first architecture works reliably across different domains and use cases, providing users with confidence that they can build upon these base workflows for their specific needs.