Skip to content

Commit

Permalink
build: Use drf-spectacular for docs, remove edx_api_doc_tools
Browse files Browse the repository at this point in the history
  • Loading branch information
zamanafzal committed Dec 27, 2023
1 parent eb9407e commit 4facfa4
Show file tree
Hide file tree
Showing 13 changed files with 589 additions and 416 deletions.
13 changes: 10 additions & 3 deletions license_manager/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
'djangoql',
'durationwidget',
'rest_framework',
'drf_yasg',
'edx_api_doc_tools',
'drf_spectacular',
'rules.apps.AutodiscoverRulesConfig',
'simple_history',
'simplejson',
Expand Down Expand Up @@ -146,7 +145,7 @@
'rest_framework.permissions.IsAuthenticated',
'rest_framework.permissions.IsAdminUser',
],
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
'PAGE_SIZE': 100,
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
'DEFAULT_THROTTLE_CLASSES': [
Expand Down Expand Up @@ -445,3 +444,11 @@

# disable indexing on history_date
SIMPLE_HISTORY_DATE_INDEX = False

# DRF Spectacular settings
SPECTACULAR_SETTINGS = {
'TITLE': 'License Manager API',
'DESCRIPTION': 'API for querying and commanding about license manager records.',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
}
26 changes: 18 additions & 8 deletions license_manager/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
from django.conf import settings
from django.contrib import admin
from django.urls import include, path
from drf_yasg.views import get_schema_view
from edx_api_doc_tools import make_api_info
from drf_spectacular.views import (
SpectacularAPIView,
SpectacularRedocView,
SpectacularSwaggerView,
)
from rest_framework import permissions

from license_manager.apps.api import urls as api_urls
Expand All @@ -30,12 +33,15 @@

admin.autodiscover()

spectacular_view = SpectacularAPIView(
api_version='v1',
title='license manager spectacular view',
)
spec_swagger_view = SpectacularSwaggerView()

api_info = make_api_info(title="License Manager API", version="v1")
schema_view = get_schema_view(
api_info,
public=False,
permission_classes=(permissions.AllowAny,),
spec_redoc_view = SpectacularRedocView(
title='Redoc view for the license manager API.',
url_name='schema',
)

urlpatterns = [
Expand All @@ -44,9 +50,13 @@
path('admin/', admin.site.urls),
path('admin-custom/subscriptions/', include(subs_url_admin)),
path('api/', include(api_urls)),
path('api-docs/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path('auto_auth/', core_views.AutoAuth.as_view(), name='auto_auth'),
path('health/', core_views.health, name='health'),
# All the API docs
path('api-docs/', spec_swagger_view.as_view(), name='api-docs'),
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
path('api/schema/redoc/', spec_redoc_view.as_view(url_name='schema'), name='redoc'),
path('api/schema/swagger-ui/', spec_swagger_view.as_view(url_name='schema'), name='swaggger-ui'),
]


Expand Down
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ django-extensions
django-filter
django-model-utils
djangoql
drf-spectacular
django-ses
rules
django-simple-history
django-waffle
djangorestframework
djangorestframework-csv
drf-nested-routers
edx-api-doc-tools
edx-auth-backends
edx-braze-client
edx-celeryutils
Expand Down
112 changes: 65 additions & 47 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
#
# make upgrade
#
amqp==5.1.1
amqp==5.2.0
# via kombu
analytics-python==1.4.post1
# via -r requirements/base.in
asgiref==3.7.2
# via django
async-timeout==4.0.3
# via redis
# via
# django
# django-cors-headers
attrs==23.1.0
# via
# jsonschema
# referencing
backoff==1.10.0
# via
# -r requirements/base.in
Expand All @@ -21,26 +25,26 @@ backports-zoneinfo[tzdata]==0.2.1
# celery
# django
# kombu
billiard==4.1.0
billiard==4.2.0
# via celery
boto3==1.28.75
boto3==1.34.7
# via django-ses
botocore==1.31.75
botocore==1.34.7
# via
# boto3
# s3transfer
celery==5.3.4
celery==5.3.6
# via
# -r requirements/base.in
# django-celery-results
# edx-celeryutils
certifi==2023.7.22
certifi==2023.11.17
# via requests
cffi==1.16.0
# via
# cryptography
# pynacl
charset-normalizer==3.3.1
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via
Expand All @@ -58,15 +62,15 @@ click-repl==0.3.0
# via celery
code-annotations==1.5.0
# via edx-toggles
cryptography==41.0.5
cryptography==41.0.7
# via
# pyjwt
# social-auth-core
defusedxml==0.8.0rc2
# via
# python3-openid
# social-auth-core
django==4.2.6
django==4.2.8
# via
# -c requirements/constraints.txt
# -r requirements/base.in
Expand All @@ -84,8 +88,7 @@ django==4.2.6
# djangorestframework
# drf-jwt
# drf-nested-routers
# drf-yasg
# edx-api-doc-tools
# drf-spectacular
# edx-auth-backends
# edx-celeryutils
# edx-django-utils
Expand All @@ -98,7 +101,7 @@ django-autocomplete-light==3.9.7
# via -r requirements/base.in
django-celery-results==2.5.1
# via -r requirements/base.in
django-cors-headers==4.3.0
django-cors-headers==4.3.1
# via -r requirements/base.in
django-crum==0.7.9
# via
Expand All @@ -109,7 +112,7 @@ django-durationwidget==1.0.5
# via -r requirements/base.in
django-extensions==3.2.3
# via -r requirements/base.in
django-filter==23.3
django-filter==23.5
# via -r requirements/base.in
django-log-request-id==2.1.0
# via -r requirements/base.in
Expand All @@ -118,50 +121,47 @@ django-model-utils==4.3.1
# -r requirements/base.in
# edx-celeryutils
# edx-rbac
django-ses==3.5.0
django-ses==3.5.2
# via -r requirements/base.in
django-simple-history==3.4.0
# via -r requirements/base.in
django-waffle==4.0.0
django-waffle==4.1.0
# via
# -r requirements/base.in
# edx-django-utils
# edx-drf-extensions
# edx-toggles
djangoql==0.17.1
djangoql==0.18.0
# via -r requirements/base.in
djangorestframework==3.14.0
# via
# -r requirements/base.in
# djangorestframework-csv
# drf-jwt
# drf-nested-routers
# drf-yasg
# edx-api-doc-tools
# drf-spectacular
# edx-drf-extensions
djangorestframework-csv==3.0.1
djangorestframework-csv==3.0.2
# via -r requirements/base.in
drf-jwt==1.19.2
# via edx-drf-extensions
drf-nested-routers==0.93.4
drf-nested-routers==0.93.5
# via -r requirements/base.in
drf-yasg==1.21.7
# via edx-api-doc-tools
edx-api-doc-tools==1.7.0
drf-spectacular==0.27.0
# via -r requirements/base.in
edx-auth-backends==4.2.0
# via -r requirements/base.in
edx-braze-client==0.1.8
# via -r requirements/base.in
edx-celeryutils==1.2.3
# via -r requirements/base.in
edx-django-utils==5.7.0
edx-django-utils==5.9.0
# via
# -r requirements/base.in
# edx-drf-extensions
# edx-rest-api-client
# edx-toggles
edx-drf-extensions==8.13.0
edx-drf-extensions==9.0.1
# via
# -r requirements/base.in
# edx-rbac
Expand All @@ -173,10 +173,14 @@ edx-rest-api-client==5.6.1
# via -r requirements/base.in
edx-toggles==5.1.0
# via -r requirements/base.in
idna==3.4
idna==3.6
# via requests
importlib-resources==6.1.1
# via
# jsonschema
# jsonschema-specifications
inflection==0.5.1
# via drf-yasg
# via drf-spectacular
jinja2==3.1.2
# via code-annotations
jmespath==1.0.1
Expand All @@ -185,29 +189,33 @@ jmespath==1.0.1
# botocore
jsonfield==3.1.0
# via edx-celeryutils
kombu==5.3.2
jsonschema==4.20.0
# via drf-spectacular
jsonschema-specifications==2023.12.1
# via jsonschema
kombu==5.3.4
# via celery
markupsafe==2.1.3
# via jinja2
monotonic==1.6
# via analytics-python
mysqlclient==2.2.0
mysqlclient==2.2.1
# via -r requirements/base.in
newrelic==9.1.1
newrelic==9.3.0
# via edx-django-utils
oauthlib==3.2.2
# via
# requests-oauthlib
# social-auth-core
packaging==23.2
# via drf-yasg
pbr==5.11.1
pbr==6.0.0
# via stevedore
pkgutil-resolve-name==1.3.10
# via jsonschema
ply==3.11
# via djangoql
prompt-toolkit==3.0.39
prompt-toolkit==3.0.43
# via click-repl
psutil==5.9.6
psutil==5.9.7
# via edx-django-utils
pycparser==2.21
# via cffi
Expand Down Expand Up @@ -237,13 +245,16 @@ pytz==2023.3.post1
# -r requirements/base.in
# django-ses
# djangorestframework
# drf-yasg
pyyaml==6.0.1
# via
# code-annotations
# drf-yasg
# drf-spectacular
redis==5.0.1
# via -r requirements/base.in
referencing==0.32.0
# via
# jsonschema
# jsonschema-specifications
requests==2.31.0
# via
# analytics-python
Expand All @@ -254,9 +265,13 @@ requests==2.31.0
# social-auth-core
requests-oauthlib==1.3.1
# via social-auth-core
rpds-py==0.15.2
# via
# jsonschema
# referencing
rules==3.3
# via -r requirements/base.in
s3transfer==0.7.0
s3transfer==0.10.0
# via boto3
semantic-version==2.10.0
# via edx-drf-extensions
Expand All @@ -273,7 +288,7 @@ slumber==0.7.1
# via edx-rest-api-client
social-auth-app-django==5.4.0
# via edx-auth-backends
social-auth-core==4.5.0
social-auth-core==4.5.1
# via
# edx-auth-backends
# social-auth-app-django
Expand All @@ -286,27 +301,30 @@ stevedore==5.1.0
# edx-opaque-keys
text-unidecode==1.3
# via python-slugify
typing-extensions==4.8.0
typing-extensions==4.9.0
# via
# asgiref
# drf-spectacular
# edx-opaque-keys
# kombu
tzdata==2023.3
# via
# backports-zoneinfo
# celery
uritemplate==4.1.1
# via drf-yasg
# via drf-spectacular
urllib3==1.26.18
# via
# botocore
# requests
vine==5.0.0
vine==5.1.0
# via
# amqp
# celery
# kombu
wcwidth==0.2.9
wcwidth==0.2.12
# via prompt-toolkit
zipp==3.17.0
# via -r requirements/base.in
# via
# -r requirements/base.in
# importlib-resources
Loading

0 comments on commit 4facfa4

Please sign in to comment.