From 13cbb33c988f80c5664f1bb658b30404d1c27014 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Tue, 4 Apr 2023 05:23:56 -0700 Subject: [PATCH] 12148 add swagger-sidecar for self-hosted swagger docs (#12159) * 12148 add swagger-sidecar for self-hosted swagger docs * 12149 add to base_requirements --- base_requirements.txt | 4 ++++ netbox/netbox/settings.py | 4 ++++ requirements.txt | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/base_requirements.txt b/base_requirements.txt index 6e94f4daf..02de205fa 100644 --- a/base_requirements.txt +++ b/base_requirements.txt @@ -70,6 +70,10 @@ djangorestframework # https://github.com/tfranzel/drf-spectacular drf-spectacular +# Serve self-contained distribution builds of Swagger UI and Redoc with Django. +# https://github.com/tfranzel/drf-spectacular-sidecar +drf-spectacular-sidecar + # RSS feed parser # https://github.com/kurtmckee/feedparser feedparser diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 3b162b261..14b00a76f 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -345,6 +345,7 @@ INSTALLED_APPS = [ 'wireless', 'django_rq', # Must come after extras to allow overriding management commands 'drf_spectacular', + 'drf_spectacular_sidecar', ] # Middleware @@ -584,6 +585,9 @@ SPECTACULAR_SETTINGS = { "LICENSE": {"name": "Apache v2 License"}, "VERSION": VERSION, 'COMPONENT_SPLIT_REQUEST': True, + 'SWAGGER_UI_DIST': 'SIDECAR', + 'SWAGGER_UI_FAVICON_HREF': 'SIDECAR', + 'REDOC_DIST': 'SIDECAR', } # diff --git a/requirements.txt b/requirements.txt index e557f88c2..674a57b95 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,8 @@ django-tables2==2.5.3 django-taggit==3.1.0 django-timezone-field==5.0 djangorestframework==3.14.0 -drf-spectacular==0.25.1 +drf-spectacular==0.26.1 +drf-spectacular-sidecar==2023.4.1 feedparser==6.0.10 graphene-django==3.0.0 gunicorn==20.1.0