Skip to content

Commit

Permalink
🚀 Use local swagger ui for drf-spectacular
Browse files Browse the repository at this point in the history
This commit disabled redoc, because it is not easily possible to deploy a redoc copy that does not load external resources
  • Loading branch information
pajowu authored and stefanw committed Jan 10, 2023
1 parent a72bb17 commit f5e9697
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
7 changes: 7 additions & 0 deletions froide/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Base(Configuration):
"oauth2_provider",
"rest_framework",
"drf_spectacular",
"drf_spectacular_sidecar",
]
)

Expand Down Expand Up @@ -650,6 +651,12 @@ def STATICFILES_DIRS(self):
UNSUBSCRIBE_EMAIL_ACCOUNT_PASSWORD = values.Value("")
UNSUBSCRIBE_EMAIL_USE_SSL = values.Value(False)

SPECTACULAR_SETTINGS = {
"SWAGGER_UI_DIST": "SIDECAR",
"SWAGGER_UI_FAVICON_HREF": "SIDECAR",
"REDOC_DIST": "SIDECAR",
}


class Dev(Base):
pass
Expand Down
7 changes: 1 addition & 6 deletions froide/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.urls import include, path, reverse
from django.utils.translation import pgettext_lazy

from drf_spectacular.views import SpectacularRedocView, SpectacularSwaggerView
from drf_spectacular.views import SpectacularSwaggerView
from rest_framework.schemas import get_schema_view

from froide.account.api_views import ProfileView, UserPreferenceView
Expand Down Expand Up @@ -136,11 +136,6 @@ def location(self, item):
SpectacularSwaggerView.as_view(url_name="schema"),
name="swagger-ui",
),
path(
"api/v1/schema/redoc/",
SpectacularRedocView.as_view(url_name="schema"),
name="redoc",
),
]


Expand Down
5 changes: 4 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ django==4.1.4
# django-treebeard
# djangorestframework
# drf-spectacular
# drf-spectacular-sidecar
# easy-thumbnails
django-appconf==1.0.5
# via django-celery-email
Expand Down Expand Up @@ -178,8 +179,10 @@ djangorestframework-jsonp==1.0.2
# via -r requirements.in
dnspython==2.2.1
# via pyisemail
drf-spectacular==0.25.1
drf-spectacular[sidecar]==0.25.1
# via -r requirements.in
drf-spectacular-sidecar==2022.12.1
# via drf-spectacular
easy-thumbnails==2.8.4
# via -r requirements.in
elasticsearch==7.17.8
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Django>=4.1,<4.2
djangorestframework
djangorestframework-csv
djangorestframework-jsonp
drf-spectacular
drf-spectacular[sidecar]
easy-thumbnails
elasticsearch-dsl>=7.0.0<8.0.0
elasticsearch<8.0.0,>=7.0.0
Expand Down
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ django==4.1.4
# django-treebeard
# djangorestframework
# drf-spectacular
# drf-spectacular-sidecar
# easy-thumbnails
django-appconf==1.0.5
# via django-celery-email
Expand Down Expand Up @@ -157,8 +158,10 @@ djangorestframework-jsonp==1.0.2
# via -r requirements.in
dnspython==2.2.1
# via pyisemail
drf-spectacular==0.25.1
drf-spectacular[sidecar]==0.25.1
# via -r requirements.in
drf-spectacular-sidecar==2022.12.1
# via drf-spectacular
easy-thumbnails==2.8.4
# via -r requirements.in
elasticsearch==7.17.8
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def find_version(*file_paths):
"django-filingcabinet",
"icalendar",
"easy-thumbnails",
"drf-spectacular",
"drf-spectacular[sidecar]",
],
extras_require=extras,
include_package_data=True,
Expand Down

0 comments on commit f5e9697

Please sign in to comment.