Version 0.1.0
A Python-based API contract validation system that ensures Production API responses comply with UAT-approved contracts. Validates both SOAP (XML) and REST (JSON) APIs by generating schemas from UAT responses and detecting contract violations in Production environments.
APIProof provides QA and engineering teams with an automated solution to validate API contract compliance across environments. The system treats UAT-approved responses as the signed-off baseline contract and validates Production responses against this baseline to detect structural violations and ensure environment consistency.
Key Features:
- 🔄 Dual Protocol Support - Validates both SOAP (XML) and REST (JSON) APIs
- 📋 Schema Generation - Automatically generates XSD and JSON schemas from UAT responses
- ✅ Contract Validation - Validates PROD responses against generated schemas
- 📊 HTML Reports - Produces detailed HTML reports showing validation results and violations
- ⚡ Batch Processing - Process multiple endpoints/response types in one command
- 🔍 Value Difference Detection - Distinguishes between structural violations and data value differences
This project is licensed under the Apache License 2.0 - see the LICENSE file for full terms.
Copyright 2024–2025 Devify LLC
- Python 3.8 or higher (recommended: 3.10+)
- pip 20.x or higher
- lxml 4.9.0+ - XML processing and XSD validation
- xmlschema 2.0.0+ - XSD schema generation
- jsonschema 4.0.0+ - JSON schema validation
- jinja2 3.1.0+ - HTML report templating
- pytest 7.0.0+ (optional, for testing)
- Clone the repository
git clone https://github.com/devifyllc/apiproof.git
cd apiproof- Create a virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txtSingle Validation:
# Run full SOAP validation workflow
python3 soap_validator.py full-workflow \
samples/soap/uat-approved/ADDRESS_FIELDS-approved.xml \
samples/soap/prod-actual/ADDRESS_FIELDS-actual.xmlBatch Validation:
# Validate all SOAP response pairs
python3 validate_all.pyView Reports:
# Open the generated report
open reports/soap/ADDRESS_FIELDS-validation-report.htmlSingle Validation:
# Run full REST validation workflow
python3 rest_validator.py full-workflow \
samples/rest/uat-approved/ADDRESS_FIELDS-approved.json \
samples/rest/prod-actual/ADDRESS_FIELDS-actual.jsonBatch Validation:
# Validate all REST endpoint pairs
python3 validate_rest_all.pyView Reports:
# Open the generated report
open reports/rest/ADDRESS_FIELDS-validation-report.htmlRun the installation verification script:
python3 verify_installation.pyapiproof/
├── src/ # Core source code
│ ├── __init__.py # Package initialization
│ ├── exceptions.py # Custom exception hierarchy
│ ├── models.py # Data models and structures
│ ├── xml_parser.py # XML parsing utilities
│ ├── schema_generator.py # Schema generation logic
│ └── pretty_printer.py # XML formatting utilities
├── tests/ # Test suite
│ ├── __init__.py
│ ├── test_exceptions.py
│ ├── test_models.py
│ ├── test_schema_generator.py
│ └── test_xml_parser.py
├── samples/ # Sample API responses
│ ├── soap/
│ │ ├── uat-approved/ # UAT-approved SOAP responses
│ │ └── prod-actual/ # PROD SOAP responses to validate
│ └── rest/
│ ├── uat-approved/ # UAT-approved REST responses
│ └── prod-actual/ # PROD REST responses to validate
├── contracts/ # Generated schemas
│ ├── soap/ # XSD schemas
│ └── rest/ # JSON schemas
├── reports/ # Generated HTML reports
│ ├── soap/ # SOAP validation reports
│ └── rest/ # REST validation reports
├── soap_validator.py # SOAP validation CLI
├── rest_validator.py # REST validation CLI
├── validate_all.py # Batch SOAP validation
├── validate_rest_all.py # Batch REST validation
├── generate_all_schemas.py # Batch schema generation
├── verify_installation.py # Installation verification
├── requirements.txt # Python dependencies
├── pyproject.toml # Package configuration
├── .gitignore # Git ignore patterns
└── README.md # This file
- Schema Generation: Parse UAT-approved response and generate a formal schema (XSD for SOAP, JSON Schema for REST)
- Schema Storage: Save the schema to
contracts/directory for reuse - PROD Validation: Parse PROD response and validate against the generated schema
- Report Generation: Create detailed HTML report showing violations and differences
- Parses UAT-approved SOAP XML response
- Generates permissive XSD schema from structure
- Validates PROD SOAP response against XSD schema
- Detects structural violations and data differences
- Parses UAT-approved JSON response
- Infers JSON Schema from structure and types
- Validates PROD JSON response against JSON Schema
- Detects schema violations and type mismatches
- UAT-approved:
{ResponseType}-approved.xml(e.g.,ADDRESS_FIELDS-approved.xml) - PROD actual:
{ResponseType}-actual.xml(e.g.,ADDRESS_FIELDS-actual.xml) - Generated schema:
{ResponseType}-schema.xsd(auto-generated)
- UAT-approved:
{endpoint}-approved.json(e.g.,ADDRESS_FIELDS-approved.json) - PROD actual:
{endpoint}-actual.json(e.g.,ADDRESS_FIELDS-actual.json) - Generated schema:
{endpoint}-schema.json(auto-generated)
Run the test suite:
# Run all tests
pytest
# Run with coverage
pytest --cov=src --cov-report=html
# Run specific test file
pytest tests/test_models.py -vContributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes and test thoroughly
- Run tests:
pytest - Run type checking (if applicable)
- Commit your changes with clear messages
- Push to your fork and submit a pull request
For issues, questions, or feature requests, please open an issue on the GitHub repository.
Built with ❤️ by Devify LLC
A Python-based API contract validation system that ensures Production API responses comply with UAT-approved contracts. Validates both SOAP (XML) and REST (JSON) APIs by generating schemas from UAT responses and detecting contract violations in Production environments. Perfect for QA teams ensuring API contract compliance across environments.