Serve an offline API reference at /api/docs/

The Swagger UI page was blank on networks where the jsdelivr CDN is
unreachable (here the proxy answers 407), so /api/docs/ now returns a
server-rendered reference built from the same OpenAPI schema: inline
CSS/JS, no external requests, search across methods.

- Extract the renderer into apps/common/api_docs.py
- Add api_docs_view and route it to /api/docs/
- Move Swagger UI to /api/swagger/, keep ReDoc at /api/redoc/
- Let export_api_docs reuse the shared renderer (new search field)
- Update the docs entry points in docs/architecture.md
This commit is contained in:
apuc committed 2026-11-22 22:09:41 +03:00
1 parent f6c61ff8da
commit 3b3e5c429a
5 files changed
+450 -332

No files matched your search

+6 -1
View File
@@ -9,6 +9,8 @@ from drf_spectacular.views import (
SpectacularSwaggerView,
)
from apps.common.api_docs import api_docs_view
admin.site.site_header = "HOMM — управление магазином"
admin.site.site_title = "HOMM Admin"
admin.site.index_title = "Панель управления"
@@ -25,8 +27,11 @@ urlpatterns = [
path("api/v1/payments/", include("apps.payments.urls")),
path("api/v1/integration/1c/", include("apps.integration.urls")),
path("api/schema/", SpectacularAPIView.as_view(), name="schema"),
# Self-contained reference: works without internet access (no CDN).
path("api/docs/", api_docs_view, name="api-docs"),
# Full Swagger UI / ReDoc: need access to the jsdelivr CDN.
path(
"api/docs/",
"api/swagger/",
SpectacularSwaggerView.as_view(url_name="schema"),
name="swagger-ui",
),