Skip to main content

🔀 swagger-diff-ui

Drop-in Swagger UI for Django + DRF that diffs your live OpenAPI schema against a git branch or commit — then paints every changed endpoint as NEW · UPDATE · DELETE.

No Node. No separate SPA. Same /api/docs/ you already open — with a small baseline drawer on top.

Schema diff UI showing NEW, UPDATE, and DELETE badges on Swagger endpoints

Pick a baseline → Compare → see what changed.


✨ What you get

Feature What it does
🌿 Branch / commit selectors Baseline from your real git history
▶️ Compare Diff current schema vs that baseline
🟢🟡🔴 NEW / UPDATE / DELETE tags On the left of every changed operation
🎯 Changed only Hide unchanged APIs (toggle anytime)
🔬 Field-level UPDATE Params, body, responses, schema props — colored dots

⚙️ Baseline export uses a temporary git worktree + manage.py spectacular. Intended for local / DEBUG only.


📦 Requirements

  • Python 3.10+
  • Django 4.2+
  • Django REST Framework
  • drf-spectacular
  • A git checkout of your project (for branch/commit baselines)

🚀 Install

From GitHub

pip install "git+https://github.com/Iman-Sharei/swagger-diff-ui.git"

From PyPI (when published)

pip install swagger-diff-ui

Local editable

pip install -e ".[dev]"

🔌 Wire into Django

Same idea as spectacular: one app + a few routes.

1️⃣ Add the app

# settings — typically local / debug only
INSTALLED_APPS = [
    # ...
    "drf_spectacular",
    "swagger_diff_ui",
]

2️⃣ Keep spectacular’s schema + include our URLs

# urls.py
from django.urls import include, path
from drf_spectacular.views import SpectacularAPIView

urlpatterns = [
    # Real OpenAPI document (unchanged)
    path("api/schema/", SpectacularAPIView.as_view(), name="api-schema"),

    # Diff UI + helpers
    path("api/", include("swagger_diff_ui.urls")),
]

3️⃣ Open the docs

http://127.0.0.1:8000/api/docs/

Done. ✅


🖱️ How to use

  1. Open /api/docs/
  2. In the dark drawer, pick a baseline branch or commit
  3. Click Compare
  4. Changed endpoints get NEW / UPDATE / DELETE
  5. Open an UPDATE row for field-level diffs + colored Example Value dots
  6. Use Changed only / Show all APIs and Hide ▴ / Show ▾

⏱️ First compare for a given SHA can take a bit (worktree + schema export). Results cache under .schema-cache/ — keep that folder in .gitignore.


🗺️ Routes

Assuming you included under api/:

URL Role
/api/docs/ Swagger UI + schema-diff drawer
/api/schema/ Your real OpenAPI schema (spectacular)
/api/swagger-diff/git-refs/ Branches + recent commits
/api/swagger-diff/diff/?ref=… Diff report vs baseline
/api/swagger-diff/baseline/?ref=… Raw baseline OpenAPI (optional)

Diff helpers live under /api/swagger-diff/… so they never collide with /api/schema/.


🔒 Safety notes

  • Git baseline APIs are gated to DJANGO_ENV == "local" or DEBUG=True
  • Do not expose these on production with DEBUG=True
  • Prefer wiring swagger_diff_ui only in local / staging settings

🧪 Develop & test

pip install -e ".[dev]"
pytest -q

📄 License

MIT · made for Django + DRF teams who live in /api/docs/

Metadata

Release files for swagger-diff-ui 0.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 swagger-diff-ui 0.1.0
File Size Uploaded Provenance Actions
swagger_diff_ui-0.1.0.tar.gz 25.3 kB Without provenance Details for swagger_diff_ui-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for swagger-diff-ui 0.1.0
File Interpreter ABI Platform Actions
swagger_diff_ui-0.1.0-py3-none-any.whl Python 3 none any Details for swagger_diff_ui-0.1.0-py3-none-any.whl

Total release size: 51.4 kB

Release files / swagger_diff_ui-0.1.0.tar.gz

Download URL swagger_diff_ui-0.1.0.tar.gz
Size 25.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c318740fe581f07aeb5d0b88e7567112b04f99240762466b585f86280515452a
BLAKE2b-256 checksum
How to use checksums
0ea398fc5c807cea80642e46c7927b153743ce13a867d8ba10d9be950212c98b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / swagger_diff_ui-0.1.0-py3-none-any.whl

Download URL swagger_diff_ui-0.1.0-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e8569d798300900d7dad5bae41c7467e9d3efec91c6d222f44f08df90c1a987
BLAKE2b-256 checksum
How to use checksums
0f1c2db47aacab830ccb3232f296335621b14b4ba5ee42580597c66d42e3a2f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for swagger-diff-ui 0.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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