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
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
"""URL configuration for the HOMM backend."""
|
|
from django.conf import settings
|
|
from django.conf.urls.static import static
|
|
from django.contrib import admin
|
|
from django.urls import include, path
|
|
from drf_spectacular.views import (
|
|
SpectacularAPIView,
|
|
SpectacularRedocView,
|
|
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 = "Панель управления"
|
|
admin.site.index_template = "admin/homm_index.html"
|
|
|
|
urlpatterns = [
|
|
path("admin/", admin.site.urls),
|
|
path("api/v1/", include("apps.common.urls")),
|
|
path("api/v1/auth/", include("apps.accounts.urls")),
|
|
path("api/v1/catalog/", include("apps.catalog.urls")),
|
|
path("api/v1/orders/", include("apps.orders.urls")),
|
|
path("api/v1/loyalty/", include("apps.loyalty.urls")),
|
|
path("api/v1/content/", include("apps.content.urls")),
|
|
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/swagger/",
|
|
SpectacularSwaggerView.as_view(url_name="schema"),
|
|
name="swagger-ui",
|
|
),
|
|
path(
|
|
"api/redoc/",
|
|
SpectacularRedocView.as_view(url_name="schema"),
|
|
name="redoc",
|
|
),
|
|
]
|
|
|
|
if settings.DEBUG:
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|