AsyncAPI Payload Validator
A Python tool for validating JSON message payloads against AsyncAPI specifications. Performs detailed JSON Schema validation including type checking, constraints, patterns, enums, and composition rules.
Features
- Comprehensive validation - types, required fields, string length, patterns, enums, numeric constraints, oneOf/anyOf/allOf
- Lenient type coercion - string numbers and booleans accepted where appropriate
- AsyncAPI 2.x and 3.x - supports both specification versions
- HTML reports - detailed reports with line-by-line source highlighting
- Jinja2 templates - validate template structure before rendering
- CI/CD ready - exit codes, GitHub Actions and GitLab CI examples
Installation
pip install asyncapi-payload-validator
Install from source
git clone https://github.com/ingka-group/asyncapi-payload-validator.git
cd asyncapi-payload-validator
pip install .
For development: pip install -e ".[dev]"
Quick Start
Command Line
# Basic validation
asyncapi-validate payload.json asyncapi-spec.yaml
# Generate HTML report
asyncapi-validate payload.json asyncapi-spec.yaml --html-report report.html
# Validate specific message by ID
asyncapi-validate payload.json asyncapi-spec.yaml --message-id UserSignedUp
# Validate Jinja2 template structure
asyncapi-validate template.json spec.yaml --render-jinja2
# Validate rendered template with context
asyncapi-validate template.json spec.yaml --render-jinja2 --jinja2-context context.json
Python Library
import json, yaml
from pathlib import Path
from asyncapi_payload_validator import validate_payload
payload = json.loads(Path('payload.json').read_text())
spec = yaml.safe_load(Path('asyncapi.yaml').read_text())
result = validate_payload(payload, spec)
if result['valid']:
print("Validation passed!")
else:
print(f"{result['summary']['total_violations']} violation(s)")
for category, violations in result['violations'].items():
for v in violations:
print(f" - {v}")
See Python API Reference for the full API, return value structure, and advanced usage.
Validation Rules
| Icon | Category | Description |
|---|---|---|
| ➕ | Extra Attributes | Fields in payload not declared in schema |
| ❌ | Type Mismatches | Incorrect data types (with lenient coercion) |
| 🚫 | Missing Required | Required fields absent from payload |
| ↔️ | Length Violations | String minLength/maxLength constraints |
| #️⃣ | Pattern Violations | Regex pattern mismatches |
| ✅ | Enum Violations | Values not in allowed enum list |
| 🔢 | Numeric Violations | min/max/multipleOf constraints |
| 🧩 | Composition Violations | oneOf/anyOf/allOf rule failures |
Exit Codes
| Code | Meaning |
|---|---|
0 |
Validation passed |
1 |
Validation failed (violations found) |
2 |
Error (invalid arguments, file not found) |
130 |
Cancelled by user (Ctrl+C) |
Documentation
| Guide | Description |
|---|---|
| Examples and Output | Output format, real-world examples, icon reference |
| Python API | Programmatic usage, return structure, individual functions |
| CI/CD Integration | GitHub Actions, GitLab CI examples |
| Advanced Features | Jinja2 templates, type coercion, composition, troubleshooting |
Contributing
Contributions are welcome! See CONTRIBUTING.md for guidelines.
License
MIT - see LICENCE.md for details.
Links
Release files for asyncapi-payload-validator 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asyncapi_payload_validator-1.0.2.tar.gz | 37.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asyncapi_payload_validator-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 69.9 kB
Release files / asyncapi_payload_validator-1.0.2.tar.gz
| Download URL | asyncapi_payload_validator-1.0.2.tar.gz |
|---|---|
| Size | 37.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b33c8fef8ad8ecfb280b881bb5ee49a1e3858675c844067a0685f221bb39e0e9
|
|
BLAKE2b-256 checksum How to use checksums |
ff90dc2db179dafdbf6c09000386affab400b93bb5f4de2ce272c7d06b151161
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2026.
Transparency logRelease files / asyncapi_payload_validator-1.0.2-py3-none-any.whl
| Download URL | asyncapi_payload_validator-1.0.2-py3-none-any.whl |
|---|---|
| Size | 32.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd97304f036549e425462dc340b3f05f2d100fd5fb3e00aea5b4a5c3996c776d
|
|
BLAKE2b-256 checksum How to use checksums |
72c2345b27aa96a1d35323510bc215c1516848ca9dc17e93c59162d9bd52da62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2026.
Transparency log