From eec767c75a49b09b3628744290c1c8dc9a7b6bc2 Mon Sep 17 00:00:00 2001 From: Irtaza Akram Date: Wed, 2 Oct 2024 11:10:59 +0500 Subject: [PATCH] fix: add redoc & spectacular settings --- notesserver/settings/common.py | 8 ++++++++ notesserver/settings/logger.py | 1 + notesserver/settings/yaml_config.py | 2 +- notesserver/urls.py | 3 ++- requirements/base.txt | 6 +++--- requirements/ci.txt | 2 +- requirements/test.txt | 11 +++++------ 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/notesserver/settings/common.py b/notesserver/settings/common.py index c29e55db..74ea1806 100644 --- a/notesserver/settings/common.py +++ b/notesserver/settings/common.py @@ -87,6 +87,14 @@ 'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema', } +SPECTACULAR_SETTINGS = { + 'TITLE': 'edx-notes-api', + 'DESCRIPTION': 'API documentation for edx-notes-api', + 'VERSION': '1.0.0', + 'SERVE_INCLUDE_SCHEMA': False, + 'SCHEMA_PATH_PREFIX': '/api/' +} + # CORS is configured to allow all origins because requests to the # Notes API do not rely on ambient authority; instead, they are # authorized explicitly via an X-Annotator-Auth-Token header. (The diff --git a/notesserver/settings/logger.py b/notesserver/settings/logger.py index cff75bfa..be084b9e 100644 --- a/notesserver/settings/logger.py +++ b/notesserver/settings/logger.py @@ -6,6 +6,7 @@ import platform import sys from logging.handlers import SysLogHandler + from django.conf import settings diff --git a/notesserver/settings/yaml_config.py b/notesserver/settings/yaml_config.py index 35fb1dbc..38262cc2 100644 --- a/notesserver/settings/yaml_config.py +++ b/notesserver/settings/yaml_config.py @@ -2,9 +2,9 @@ import yaml from django.core.exceptions import ImproperlyConfigured +from path import path from notesserver.settings.logger import build_logging_config -from path import path from .common import * # pylint: disable=unused-wildcard-import, wildcard-import diff --git a/notesserver/urls.py b/notesserver/urls.py index b0608095..77793f6a 100644 --- a/notesserver/urls.py +++ b/notesserver/urls.py @@ -1,5 +1,5 @@ from django.urls import include, path, re_path -from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView +from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView import notesserver.views @@ -11,4 +11,5 @@ path('api/', include('notesapi.urls', namespace='api')), path('api/schema/', SpectacularAPIView.as_view(), name='schema'), path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'), + path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'), ] diff --git a/requirements/base.txt b/requirements/base.txt index 396fa6ee..05398f1d 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -72,7 +72,7 @@ drf-spectacular==0.27.2 # via -r requirements/base.in edx-django-release-util==1.4.0 # via -r requirements/base.in -edx-django-utils==5.15.0 +edx-django-utils==5.16.0 # via # -r requirements/base.in # edx-drf-extensions @@ -128,7 +128,7 @@ pyjwt[crypto]==2.9.0 # -r requirements/base.in # drf-jwt # edx-drf-extensions -pymongo==4.9.1 +pymongo==4.10.1 # via edx-opaque-keys pynacl==1.5.0 # via edx-django-utils @@ -138,7 +138,7 @@ python-dateutil==2.4.0 # -r requirements/base.in # elasticsearch-dsl pytz==2024.2 - # via drf-yasg + # via -r requirements/base.in pyyaml==6.0.2 # via # drf-spectacular diff --git a/requirements/ci.txt b/requirements/ci.txt index b13ad897..8fa9d54c 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -28,7 +28,7 @@ pluggy==1.5.0 # via tox pyproject-api==1.8.0 # via tox -tox==4.20.0 +tox==4.21.0 # via -r requirements/ci.in virtualenv==20.26.6 # via tox diff --git a/requirements/test.txt b/requirements/test.txt index f274c8d7..ea169672 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -112,7 +112,7 @@ drf-spectacular==0.27.2 # via -r requirements/base.txt edx-django-release-util==1.4.0 # via -r requirements/base.txt -edx-django-utils==5.15.0 +edx-django-utils==5.16.0 # via # -r requirements/base.txt # edx-drf-extensions @@ -137,7 +137,7 @@ elasticsearch-dsl==7.4.1 # django-elasticsearch-dsl-drf factory-boy==3.3.1 # via -r requirements/test.in -faker==30.0.0 +faker==30.1.0 # via factory-boy filelock==3.16.1 # via @@ -226,7 +226,7 @@ pylint==1.5.0 # via # -c requirements/constraints.txt # -r requirements/test.in -pymongo==4.9.1 +pymongo==4.10.1 # via # -r requirements/base.txt # edx-opaque-keys @@ -252,9 +252,7 @@ python-dateutil==2.4.0 python-slugify==8.0.4 # via code-annotations pytz==2024.2 - # via - # -r requirements/base.txt - # drf-yasg + # via -r requirements/base.txt pyyaml==6.0.2 # via # -r requirements/base.txt @@ -310,6 +308,7 @@ typing-extensions==4.12.2 # via # -r requirements/base.txt # edx-opaque-keys + # faker uritemplate==4.1.1 # via # -r requirements/base.txt