Skip to main content

pytest-synapse

A pytest plugin for measuring OpenAPI contract test coverage by transparently intercepting HTTP traffic during test execution.

Key Features

  • Transparent Interception: Automatically captures HTTP requests/responses from requests, httpx, and aiohttp without modifying test code
  • OpenAPI Coverage: Maps captured traffic to your OpenAPI 3.x specification
  • Granular Metrics: Coverage for paths, HTTP methods, request bodies, response status codes, response schemas, and field-level constraints
  • Risk Assessment: Identifies high-risk untested endpoints with detailed risk scoring
  • Multiple Output Formats: CLI, JSON, CSV, and HTML reports
  • CI/CD Integration: Fail thresholds, baseline comparison, JUnit XML output, GitHub PR comments
  • Field & Constraint Coverage: Track coverage of required fields, enums, string patterns, numeric ranges, and more

Installation

pip install pytest-synapse

Quick Start

# Basic usage
pytest --openapi-spec=./openapi.yaml

# With HTML report including risk assessment
pytest --openapi-spec=./openapi.yaml --synapse-report=report.html --synapse-report-format=html

# With coverage threshold
pytest --openapi-spec=./openapi.yaml --synapse-fail-under=80

Coverage Output

==================================================
OpenAPI Coverage Report
==================================================

Paths:            3/5 (60.0%)
Operations:       5/8 (62.5%)
Request Bodies:   2/3 (66.7%)
Response Schemas: 7/12 (58.3%)

==================================================
API RISK ASSESSMENT
==================================================

RISK SUMMARY
------------------------------------------------------------
  Total Endpoints:     8
  High Risk:           2
  Medium Risk:         3
  Low Risk:            3
  Risk Score:          45.0/100

CRITICAL GAPS (High-risk + Uncovered):
  [!] DELETE /users/{id}
  [!] POST /payments

CLI Options

Option Description
--openapi-spec Path to OpenAPI spec file or URL
--synapse-report Output path for coverage report
--synapse-report-format Format: json, csv, html, cli_summary, cli_detailed
--synapse-fail-under Fail if coverage below threshold
--synapse-risk-report Include risk assessment in CLI output
--synapse-risk-report-output Export risk report to JSON file
--synapse-strict Fail on contract violations
--synapse-debug Enable debug logging

Configuration File

Create .synapse.yaml in your project root:

spec: ./openapi.yaml

thresholds:
  operations: 80
  paths: 90

ignore:
  paths:
    - /health
    - /metrics
  methods:
    - OPTIONS

risk:
  high_risk_paths:
    - /api/v1/admin/*
    - /api/v1/payments/*
  high_risk_methods:
    - DELETE
    - POST

Supported HTTP Clients

Client Sync Async
requests Yes N/A
httpx Yes Yes
aiohttp N/A Yes

Documentation

License

MIT License

Metadata

Release files for pytest-synapse 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-synapse 1.1.0
File Size Uploaded Provenance
pytest_synapse-1.1.0.tar.gz 53.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-synapse 1.1.0
File Interpreter ABI Platform
pytest_synapse-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 96.7 kB

Release files / pytest_synapse-1.1.0.tar.gz

Download URL pytest_synapse-1.1.0.tar.gz
Size 53.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4e6e2d7a987ec531a32c1d11b921b2b678795e402f528946dab1279b5cc54047
BLAKE2b-256 checksum
How to use checksums
d836d3cc0f033aa7dcbc3fad5bcf84be71539e195b7a74e3016dc4a00ef0a730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 11, 2026.

Transparency log

Release files / pytest_synapse-1.1.0-py3-none-any.whl

Download URL pytest_synapse-1.1.0-py3-none-any.whl
Size 43.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92a9822fd89e1ad3cd89ddc38ccd9dedb22ac4cad2b703e0b14c85bdf493d1e6
BLAKE2b-256 checksum
How to use checksums
8b406b4a705beaf65d6432b218e57d7e0f7e0f3bed62744a1c1bab072b20da23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 11, 2026.

Transparency log

Security for pytest-synapse 1.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_synapse-1.1.0.tar.gz

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 Jun 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page