This guide will help you set up and start using APIProof for API contract validation.
- Python 3.8 or higher
- pip (Python package installer)
- Git (for cloning the repository)
python3 --version
# Should show Python 3.8 or higher# Navigate to the project directory
cd apiproof
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activatepip install -r requirements.txtThis will install:
lxml- XML processing and XSD validationxmlschema- XSD schema generationjsonschema- JSON schema validationjinja2- HTML report templatingpytest- Testing framework (optional)
# Check if dependencies are installed
pip list
# Run a simple test (if you have test files)
pytest --versionThe following directories are already created:
apiproof/
├── src/ # Core source code ✓
├── tests/ # Test suite ✓
├── samples/ # Sample API responses
│ ├── soap/
│ │ ├── uat-approved/ # Place UAT SOAP files here
│ │ └── prod-actual/ # Place PROD SOAP files here
│ └── rest/
│ ├── uat-approved/ # Place UAT REST files here
│ └── prod-actual/ # Place PROD REST files here
├── contracts/ # Generated schemas (auto-created)
│ ├── soap/
│ └── rest/
└── reports/ # Generated reports (auto-created)
├── soap/
└── rest/
-
Place your files:
- UAT-approved SOAP response →
samples/soap/uat-approved/R0001-approved.xml - PROD SOAP response →
samples/soap/prod-actual/R0001-actual.xml
- UAT-approved SOAP response →
-
Run validation:
python3 soap_validator.py full-workflow \ samples/soap/uat-approved/R0001-approved.xml \ samples/soap/prod-actual/R0001-actual.xml -
View report:
open reports/soap/prod-vs-uat-contract-report.html
-
Place your files:
- UAT-approved REST response →
samples/rest/uat-approved/users-approved.json - PROD REST response →
samples/rest/prod-actual/users-actual.json
- UAT-approved REST response →
-
Run validation:
python3 rest_validator.py full-workflow \ samples/rest/uat-approved/users-approved.json \ samples/rest/prod-actual/users-actual.json -
View report:
open reports/rest/validation-report.html
python3 validate_all.pyThis will:
- Discover all UAT/PROD pairs in
samples/soap/ - Validate each pair
- Generate individual reports
- Create a summary report at
reports/soap/validation-summary.html
python3 validate_rest_all.pyThis will:
- Discover all UAT/PROD pairs in
samples/rest/ - Validate each pair
- Generate individual reports
- Create a summary report at
reports/rest/validation-summary.html
python3 generate_all_schemas.pyThis will generate XSD schemas for all UAT-approved SOAP responses.
- UAT:
{ResponseType}-approved.xml(e.g.,R0001-approved.xml) - PROD:
{ResponseType}-actual.xml(e.g.,R0001-actual.xml) - Schema:
{ResponseType}-schema.xsd(auto-generated)
- UAT:
{endpoint}-approved.json(e.g.,users-approved.json) - PROD:
{endpoint}-actual.json(e.g.,users-actual.json) - Schema:
{endpoint}-schema.json(auto-generated)
If you see import errors like ModuleNotFoundError:
# Make sure virtual environment is activated
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
# Reinstall dependencies
pip install -r requirements.txtIf scripts are not executable:
chmod +x soap_validator.py rest_validator.py validate_all.py- Ensure XML files are well-formed
- Check for proper namespace declarations
- Verify file encoding is UTF-8
- Ensure JSON files are valid
- Check for proper syntax (commas, brackets, quotes)
- Verify file encoding is UTF-8
# Run all tests
pytest
# Run with coverage
pytest --cov=src --cov-report=html
# Run specific test file
pytest tests/test_models.py -vThe project uses:
- pytest for testing
- pytest-cov for coverage reporting
- hypothesis for property-based testing
Target coverage:
- Line coverage: 90%
- Branch coverage: 85%
- ✅ Install dependencies
- ✅ Verify installation
- 📁 Add your sample files to
samples/directories - 🚀 Run your first validation
- 📊 Review the HTML reports
- 🔄 Set up batch processing for multiple endpoints
- Check the main README.md for detailed usage
- Review sample files in
samples/directories - Open an issue if you encounter problems
Ready to validate! 🚀