From e12ce4e596e279c4d44b0fd2f79a61b2230bef53 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Tue, 19 Aug 2025 18:16:21 -0500 Subject: [PATCH] Swagger endpoint can now be accessed with or without a trailing slash. --- apps/api/urls.py | 5 ++--- dispatcharr/urls.py | 7 +------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/apps/api/urls.py b/apps/api/urls.py index a2810f06..75a80725 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -1,11 +1,10 @@ -from django.urls import path, include +from django.urls import path, include, re_path from drf_yasg.views import get_schema_view from drf_yasg import openapi from rest_framework.permissions import AllowAny app_name = 'api' -# Configure Swagger Schema schema_view = get_schema_view( openapi.Info( title="Dispatcharr API", @@ -34,7 +33,7 @@ urlpatterns = [ # Swagger Documentation api_urls - path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), + re_path(r'^swagger/?$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), path('swagger.json', schema_view.without_ui(cache_timeout=0), name='schema-json'), ] diff --git a/dispatcharr/urls.py b/dispatcharr/urls.py index 3e891314..6335f656 100644 --- a/dispatcharr/urls.py +++ b/dispatcharr/urls.py @@ -55,12 +55,7 @@ urlpatterns = [ stream_xc, name="xc_stream_endpoint", ), - # Swagger UI - path( - "swagger/", - schema_view.with_ui("swagger", cache_timeout=0), - name="schema-swagger-ui", - ), + re_path(r"^swagger/?$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"), # ReDoc UI path("redoc/", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"), # Optionally, serve the raw Swagger JSON